Java String Interview Programs
In this section we will learn about java string interview programs or you can say java string example for interview, java string interview question, java string machine test round question with explanation and output.
String is also an important part of any programming language so that we will include a lot java string example are following below.
Java String Example
package pTutorial; public class ExampleString { public static void main(String args[]){ char ch[]={'p','T','u','t','o','r','i','a','l'}; String str1=new String(ch);// By constructor String str2="Java Program";//By String literal String str3=new String("Java String"); //By Creating string Object with parameter System.out.println(str1); System.out.println(str2); System.out.println(str3); } }
Output
pTutorial Java Program Java String
Java String length Example
package pTutorial; public class ExampleString { public static void main(String args[]){ String str2="Java Program";//By String literal int len=str2.length(); System.out.println("The length of the string : "+len); } }
Output
The length of the string : 12