- 1
How to declare a variable without entering the value during the coding? About Java.
I want to enter value at the output window
3 Respuestas
+ 3
Are talking about html, Javascript, c#, python, c++, java or India language?
+ 1
As far as I know, there is no way to declare a variable without assigning a value at the same time in Hindi or English, which are the two most used languages in India.
- 1
If you are talking about declaring a variable but use user input to assign it a value you can use a Scanner to ask for user to input a value
Example:
import java.util.Scanner;
class Example {
public static void main (String[] args) {
Scanner scan = new Scanner (System.in);
System.out.println("Please enter a value: ");
int userInput = scan.nextInt();
scan.close ();
}
}