Parsa Hejabi
String greeting = "Hello world!";
public class StringDemo { public static void main(String args[]) { char[] helloArray = { 'h', 'e', 'l', 'l', 'o', '.' }; String helloString = new String(helloArray); System.out.println(helloString); } } //hello.
public class testImmutableString { public static void main(String args[]) { String s = "salam "; s.concat("Java"); //concat() method appends the string at the end System.out.println(s); } } //will print Sachin because strings are immutable objects.
System.out.printf("The value of the float variable is " + "%f, while the value of the integer " + "variable is %d, and the string " + "is %s", floatVar, intVar, stringVar);
String fs; fs = String.format("The value of the float variable is " + "%f, while the value of the integer " + "variable is %d, and the string " + "is %s", floatVar, intVar, stringVar); System.out.println(fs);
String S = "Salam\\ Ok\' Bye\""; System.out.println(s); //Salam\ Ok ' Bye"