+ 1

How to print a sentence using next(); kn java

17th Sep 2017, 7:48 AM
Sushmitha M
Sushmitha M - avatar
2 Réponses
+ 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?
17th Sep 2017, 7:52 AM
Tashi N
Tashi N - avatar
+ 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 }
24th Jul 2018, 12:06 PM
Giorgos
Giorgos - avatar