Introduction to Strings

Strings are most widely used in Java programming. Strings basically represent a sequence of characters. In the Java programming language, strings are objects. The Java platform provides the String class to create and manipulate strings. Example: Char[] c = {‘H’,’e’,’l’,’l’,’o’}; Char[] c = {‘H’,’e’,’l’,’l’,’o’}; ‘c’ is the character array having sequence of characters and same […]

Share this article on

Create New file

There are 3 ways to create a new file in Java 1) Using java.io.File.createNewFile() method 2) Using java.io.FileOutputStream class 3) Using java.nio.file.Files from NIO API 1) Using java.io.File.createNewFile() method File file = new File("C:\\newfile1.txt");   //Creates new file and return true if file not exists and return false if file already exists boolean fvar = […]

Share this article on
< Previous Next >