//String array in java
public class Demo
{
public static void main(String args[ ])
{
String fname = "Govind";
String mname = "Ballabh";
String lname = "Khan";
public class Demo
{
public static void main(String args[ ])
{
String fname = "Govind";
String mname = "Ballabh";
String lname = "Khan";
System.out.println("========================Names===============================");
String names[] = {fname, mname, lname};
for(int i = 0; i < names.length; i++)
{
System.out.println(names[i]);
}
System.out.println("========================Cities===============================");
// we can create like this also
String cities[ ] = {"patna", "Bhopal", "Delhi"};
for(int i = 0; i < cities.length; i++)
{
System.out.println(cities[i]);
}
// we can create like this also
String cities[ ] = {"patna", "Bhopal", "Delhi"};
for(int i = 0; i < cities.length; i++)
{
System.out.println(cities[i]);
}
System.out.println("========================Language===============================");
// we can do like this also
String languages[ ] = new String[6];
languages[0] = "C";
languages[1] = "C++";
languages[2] = "Java";
languages[4] = ".Net";
languages[5] = ".Php";
for(int i = 0; i <languages.length; i++)
{
System.out.println(languages[i]);
}
}
}
// we can do like this also
String languages[ ] = new String[6];
languages[0] = "C";
languages[1] = "C++";
languages[2] = "Java";
languages[4] = ".Net";
languages[5] = ".Php";
for(int i = 0; i <languages.length; i++)
{
System.out.println(languages[i]);
}
}
}
No comments:
Post a Comment