0

if i omit the input of n then it will print the length of string otherwise 0(zero) why? please help

import java.util.Scanner; class TestClass { public static void main(String args[] ) throws Exception { Scanner s = new Scanner(System.in); int n=s.nextInt(); String word = s.nextLine(); int f=word.length(); System.out.println(f); } }

6th Mar 2018, 9:32 AM
Bahubali
Bahubali - avatar
5 Antworten
0
put ur code in play ground.
6th Mar 2018, 10:07 AM
Farshaad Heydari
Farshaad Heydari - avatar
0
do u know answer?
6th Mar 2018, 10:14 AM
Bahubali
Bahubali - avatar
0
your not clearing the scanner after getting an int
6th Mar 2018, 10:24 AM
Farshaad Heydari
Farshaad Heydari - avatar
0
i want string and integer both and i can take input with the same object s of scanner class what is wrong with it?
6th Mar 2018, 10:31 AM
Bahubali
Bahubali - avatar
0
you're not gonna put it in play ground . r. u?!!,😐
6th Mar 2018, 11:32 AM
Farshaad Heydari
Farshaad Heydari - avatar