Skip to content

Instantly share code, notes, and snippets.

@yubrajpokharel
Last active January 16, 2023 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yubrajpokharel/737dc9e8db74b7ab43fc6abc03a5a736 to your computer and use it in GitHub Desktop.
Save yubrajpokharel/737dc9e8db74b7ab43fc6abc03a5a736 to your computer and use it in GitHub Desktop.
Basic java Program structure
// Import statements (if any)
import java.util.Scanner;
// Class definition
public class Main {
// Main method
public static void main(String[] args) {
// Variable declaration and initialization
int number = 0;
// Object creation
Scanner input = new Scanner(System.in);
// Input
System.out.println("Enter a number: ");
number = input.nextInt();
// Output
System.out.println("You entered: " + number);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment