30) String
Ways to Create a String Object:
Method 1: Using "new" keyword
String nameOfSchoool = new String("DPS");package com.test.test1;
public class StringMethod1 {
public static void main(String[] args) {
String nameOfSchoool = new String("DPS");
System.out.println(nameOfSchoool);
}
}String nameOfSchoool = "DPS";package com.test.test1;
public class StringMethod2 {
public static void main(String[] args) {
String nameOfSchoool = "DPS";
System.out.println(nameOfSchoool);
}
}Last updated