Array:
1.String array
class Main{
/*Every application in Java must contain the main method. The Java compiler starts executing the code from the main method*/
public static void main(String anyVar[]){
String [] array={"1","2","3"};
System.out.println("default values of string array:"+array);
System.out.println("values for string array\nstring array[0]:"+array[0]+"\nstring array[1]:"+array[1]+
"\nstring array[2]:"+array[2]);
}
Output:
default values of string array:[Ljava.lang.String;@2a139a55
values for string array
string array[0]:1
string array[1]:2
string array[2]:3
Screenshot:
#happyCoding :)
Comments
Post a Comment