6. Basic Commands for command prompt and Basic java program
Command Line Interface
Commands for Using Command Prompt -
Here are some common commands used in the Command Prompt:
'dir'- Lists the contents of the current directory.
- Example: '
dir'
'cls'- Clears the screen.
- Example: '
cls'
'cd'- Changes the directory from the current folder to a specified folder.
- Example: '
cd foldername'
'cd..'- Moves up one directory level from the current folder to the parent folder.
- Example: '
cd..'
'drive name:'- Changes the drive.
- Example: '
C:'
'mkdir'or 'md'- Creates a new folder in the current directory.
- Example: '
mkdir foldername'or 'md foldername'
'javac -version'- Checks the version of the Java compiler.
- Example: '
javac -version'
'java -version'- Checks the version of the Java Virtual Machine (JVM).
- Example: '
java -version'
These commands will help you navigate and manage directories, check Java versions, and perform various tasks in the Command Prompt.
Basic Java Program
class hello
{ // Class block starts from here.
public static void main(string[]args)
{ // Method block starts from here.
System.out.println("Hello world !!") ;
} // Method block ends here.
} // Class block ends here.
This is a basic java program to print Hello world!! where we have class name as hello.
Explanation of program
Class Declaration
class hello { ... }
- Defines a class named
hello. In Java, every application begins with a class definition.
Main Method
public static void main(String[] args) { ... }
- The main method is the entry point of any Java application. It is a static method, which means it belongs to the class rather than instances of the class.
Print Statement
System.out.println("Hello world!!");
- This line prints the text "Hello world!!" to the console. The
System.out.println method is used to print output in Java.
Class Declaration
class hello { ... }
- Defines a class named
hello. In Java, every application begins with a class definition.
Main Method
public static void main(String[] args) { ... }
- The main method is the entry point of any Java application. It is a static method, which means it belongs to the class rather than instances of the class.
Print Statement
System.out.println("Hello world!!");
- This line prints the text "Hello world!!" to the console. The
System.out.printlnmethod is used to print output in Java.
Comments
Post a Comment