-5
我應該怎麼做才能讀取數組並顯示它。 我嘗試使用這些,但input.next()有錯誤;Java數組我應該怎麼做才能從數組中讀取並顯示
import java.util.*;
public class StringeEX
{
static Scanner input = new Scanner(System.in).useDelimiter("\r\n");
public static void main(String[] args)
{
String ColourOne[] ={"Black","Brown","Red","Orange","Yellow","Green","Blue","Violet","Grey","White"};
System.out.println("==========================================================");
System.out.println("Black = 0," + "\t" + "Brown = 1," + "\t" + "Red = 2,"+ "\t" +"Orange = 3");
System.out.println("Yellow = 4," + "\t" + "Green = 5," + "\t" + "Blue = 6," + "\t" +"Violet = 7");
System.out.println("*** NOTE: ***"+"\t"+"Grey = 8,"+ "\t"+"white = 9");
System.out.println("==========================================================");
System.out.print("Please enter the number for the colour :");
ColourOne = input.next();
for(int i = 0; i < ColourOne.length; i++)
System.out.println(ColourOne[i]);
}
}
http://docs.oracle.com/javase/specs/jls/se7/html/jls-10.html – hmjd
嚴重的是,哥們?在發佈之前閱讀關於java的書。 – Thom
你可能想看看循環:http://en.wikipedia.org/wiki/For_loop – home