Declare a String variable called name.
In the line where we declare the variable, immediately assign it some value.
Display the variable name on the screen.
Requirements:
In the main method, declare a String variable.
The variable must be called name.
The variable must be assigned a value immediately.
The program should display text on the screen.
The output text should be the value of the variable.
package com.codegym.task.task01.task0110;
/*
A variable on our screen
*/
public class Solution {
public static void main(String[] args) {
String s = "sumanth";
System.out.print("s");
}
}
1. you have to declare a variable name as "name" only,because the compiler designed to evaluate the every lines as described on the condition.
2.while printing the declare variable in print statement there is no need foe using the double courats(").
change your variable name from s to name. As conditions state that variable must be called name. and also you don't need to add parentheses in print method to declare a variable
This website uses cookies to provide you with personalized service. By using this website, you agree to our use of cookies. If you require more details, please read our Terms and Policy.