Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

static strings

807598Oct 19 2006 — edited Oct 19 2006
I am trying to declare strings at the top of my main method and then print them in another method. This is the first code in main
public static void main(String[] args)
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    String s = new String() ;
		boolean pb = true;
		int xc = 0;
		int yc = 0;
		String[] items = new String[10];
		items[0] = "health potion";
		items[1] = "";
		items[2] = "-";
		items[3] = "-";
		items[4] = "-";
		items[5] = "-";
		items[6] = "-";
		items[7] = "-";
		items[8] = "-";
		items[9] = "-";
and this the other method
public static void inv()
	{
		for (int i = 0; i <= 9; i ++)
					{
						System.out.println(items);
}
System.out.println ("");

}


the error message is

cannot find symbol
symbol: variable items
location: class keypad
System.out.println(items[i]);

cuold someone please explain to me? thanks for any replies
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2006
Added on Oct 19 2006
11 comments
150 views