- #1
bikashdaga
- 4
- 2
I wanted to declare a local variable inside a static method main().
My code looks like this -
Is it something I am doing right?
I have read this [Spam link deleted by the Mentors] to understand if what I am writing is correct or not but I believe asking here will give me some sort of answer.
My code looks like this -
Java:
class Operator
{
static int a;
public static void input() {
Scanner in=new Scanner(System.in);
System.out.println("Enter the number:");
a=in.nextInt(); //this is nextInt and NOT Nextint
}
public static void output() {
System.out.println("Number is:" + a);
}
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
input();
output();
}
}
Is it something I am doing right?
I have read this [Spam link deleted by the Mentors] to understand if what I am writing is correct or not but I believe asking here will give me some sort of answer.
Last edited by a moderator: