+ 5
Help me, please. Why there is no value for s2 variable?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a; String s1, s2; s1=sc.nextLine(); a=sc.nextInt(); s2=sc.nextLine(); System.out.println("a=" + a); System.out.println("s1="+s1); System.out.println("s2="+s2); } }
5 ответов
+ 5
s1=sc.nextLine();
a=sc.nextInt();
sc.nextLine();
s2=sc.nextLine();
Check Ipang's answer to understand why👇
https://www.sololearn.com/Discuss/2099456/?ref=app
ROSA Sorry😅.👆
+ 4
Just do this :
s1 = sc.nextLine();
s2 = sc.nextLine();
a = sc.nextInt();
+ 4
How to view lpang's answer?
+ 4
Thanks a lot, it's working
+ 2
Thank you, but I need that order of variable declaration