2009年2月19日 星期四

第176題

Place the code fragments into position to produce the output: true true false

Code

Scanner scanner = new Scanner("One,5,true,3,true,6,7,false);
scanner.useDelimiter(",");
while( Place hete ){
if( Place hete ){
System.out.print( Place hete + " ");
}else Place hete ;
}
Code Fragments
scanner.hasNextBoolean()
scanner.nextBoolean()
scanner.next()
scanner.hasNext()
答案:

Code

Scanner scanner = new Scanner("One,5,true,3,true,6,7,false);
scanner.useDelimiter(",");
while( scanner.hasNext() ){
if( scanner.hasNextBoolean() ){
System.out.print( scanner.nextBoolean() + " ");
}else scanner.next() ;
}

參考:11-5-2 Scanner類別

沒有留言:

張貼留言