• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using nextint to read a file

 
Kd Martin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i'm reading this line of a file: "Number of Students: 9"
is it necessary to say:
in2.next(); in2.next(); in2.next();
int uNumStudents = in2.nextInt();

Or can I just do int uNumStudents = in2.nextInt(); ? Thanks!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to subscribe to your newsletter.
 
Greg Charles
Sheriff
Posts: 3002
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, no. what you want is:

int uNumStudents = 9;

I swear, noobs always make things more complicated than they have to be.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic