declaring string in java code example

Example 1: java variable in string

String string = String.format("A string %s", aVariable);

Example 2: how to make a string java

String newString = "Hello World";

Example 3: declare String in java

String stringName = "your string content";

Example 4: string method example in java

public char charAt(int index)
-----------------------------
String x = "airplane";
System.out.println( x.charAt(2) ); // output is 'r'

Example 5: string java

char data[] = {'a', 'b', 'c'};
     String str = new String(data);

Tags:

Java Example