0
Help i`m a newbie
I want to use scanner to put 2 inputs assigned to each value(a,b) how can i do that? sorry if its not the area, here`s the code i wrote above import java.util.Scanner; class BananaVerde{ static String sum(String a, String b) { return a + b; } public static void main(String[] args){ Scanner test = new Scanner (System.in); String a = test.nextlnt(); String b = test.nextlnt(); String New = sum(a,b); System.out.print(New); } }
2 Respuestas
0
Well the error that you're doing is trying to assign an int vale to a string.
If the values you'll be taking in are integers, then either change the variable type to int/double or follow the steps below.
You can do
String a = Integer.toString(test.nextInt);
and repeat the process for String b.
0
Thank you