+ 1
How to input a string to be printed as name in Java?
Hello, I usually use python to code, but I wanted to try Java. I want to code a program that reads the age and the name of the user and prints it to the output of the editor of SoloLearn. https://code.sololearn.com/cwu1n6nQy6xy/?ref=app
7 odpowiedzi
+ 5
Elias ,
as i can see in your profile, you have joined sololearn just a view hours ago. you also have started the c# tutorial (1% finished).
from my point of view it doesn't make a lot of sense to do some experiments in java now, without having learned the basics.
please focus on one programming language to start learning how to code. if you get stuck then, you can come back and ask for help.
thanks for your understanding
+ 3
The scanner method is .nextLine()
if you want to try Java, you can start the Java course at sololearn. Getting input is described at the beginning.
https://www.w3schools.com/java/java_user_input.asp
+ 2
Lothar depends on how much experience one has before joining sololearn, I'd say...
Still, taking the sololearn course should help getting familiar with the syntax
+ 1
Ok, thank you really much😄
+ 1
Thank you!😁
0
I coded a lot of python before and a little bit of C# before
0
Your code fixed. I marked with //* where I made changes.
import java.util.Scanner; //*
public class Program
{
public static void main(String[] args) {
System.out.println("Hello World!");
Scanner sc = new Scanner(System.in); //*
String age = sc.nextLine(); //*
for(int i = 0; i<=100; i++) {
System.out.println(i);
}
System.out.println(age);
}
}