• Post Reply Bookmark Topic Watch Topic
  • New Topic

using nextint to read a file  RSS feed

 
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!
 
author and iconoclast
Sheriff
Posts: 24218
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to subscribe to your newsletter.
 
Sheriff
Posts: 3015
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!