Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: James Rivera   on Nov 14 In Java Category.

  
Question Answered By: Landra Schmidt   on Nov 14

String s[];

will just declare a String array  named "s" without
array length nor any values.

u can c my example for any idea...

public class ArrayDemo
{
public static void main(String args[])
{
String s[]; // Declare Array
s = new String[3]; // Initialize array with the
length(3)

s[0] = "Apple"; // Assign value for array's first
cell
s[1] = "Mango"; // Assign value for array's second
cell
s[2] = "Banana"; // Assign value for array's third
cell

for(int i=0;i<s.length;i++)
System.out.println((i+1) + ". " + s[i]); ////
Prints the array
}
}

Share: