Sc.next() instead of sc.nextString()

So I was programming when I realized that after taking an integer input from user sc.nextString() does not work but sc.next() does, why?

sc.nextString() takes input as string and not as integer while next() takes the input in integer and string both. So basically you can either use sc.next() or sc.nextInt().

1 Like