0
How to type unknown number of char element here(short program)
public static GPA() { int grades; int numgrades=0; char i; ArrayList<Character> niz= new ArrayList<Character>(); Scanner s=new Scanner(System.in); System.out.println("add char"); (HOW TO ADD CHAR ARRAY) }
2 ответов
0
while((i=s.next().charAt(0))<0 ){
niz.add(i);
System.out.println(niz);
CAN I USE THIS?
0
there is problem how to stop input of chars
//this reads separate char<enter> and ends if user enters empty line
String str;
while( ! (str = s.nextLine()).isEmpty() )
niz.add(str.charAt(0));
// or you can get it as one String<enter>
for (char c: s.nextLine() .toCharArray() )
niz.add(c);