+ 1
How to print a sentence using next(); kn java
2 ответов
+ 6
You mean the method next() of the Scanner class?
But that doesn't print anything, it's for taking input...
*confused* Could you pls tell us what you want to do or add an example?
+ 1
try this:
File f = new File(insert the path here);
Scaner sc = new Scaner(f);
while(sc.hasNext){
System.out.print(sc.next)
}
If you want to print the items of an ArrayList try this:
ArrayList<Integer> al = new ArrayList<Integer>();
al={1,2,3,4,5}
Iterator it = al.iterator;
while(it.hasNext){
System.out.print(it.next);
//you can use System.out.println(it.next); insted
}