0% found this document useful (0 votes)
7 views

Structure of Java

Java

Uploaded by

Madhu Chandra L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Structure of Java

Java

Uploaded by

Madhu Chandra L
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Basic Commands

1. cd– Change Directory: used to change Directory.


2. md or mkdir– Used to create directory/folder.
3. dir– used to list of all the files and directories present in the working directory.
4. cls—clears the screen.
5. javac– Used to compile a java source file. We should pass source name as input to
this as mentioned below:
javac filname.java
6. java—Used to execute java class file. We should pass class filename as an input to
this as mentioned below:
java filename
7. ../../../-- Used to move backward multiple folder.
Structure of java Program
• Java instructions are always written in a class.
class Class_Name
{
public static void main(String[] args)
{
//statements
}
}

Filename: Class_Name.java
Note: Every class in java must have a name it is known as class
name.
Every class has a block, it is known as classblock.
Members of class
• In class block we can create
 Variables
 Methods
 Initializers variable
• These are called as members of class.
1. Variables: Variable is the container which is used to store
data.
2. Methods: It is a block of instructions which is used to
perform task.
3. Initializers: Used to execute the start up instructions.
• Note: A class in java can be executed only if main method is
created as follows:
Syntax to create main method
public static void main(String[] args)
{
//Statements;
}
• Note: We can create a class without main method. It is compile
time successful and class file is generated but we can’t execute
that class file.
Difference between print and println
Statements
• System.out.println(data)
 Println statement is used to print data as well as
create a new line.
 We can use the println statement without passing
any data, it is just used for printing new line.
Example:
System.out.println(“hi”);// hi _
System.out.println(“hello”);//hello_
System.out.println();//_
Contd…..
• System.out.print()
 Print statement is used only to print the data.
 We can’t use the statement without passing any data,
if we use then will get a compile time errors.
Example:
• System.out.print(“hi”);
• System.out.print(“hello”);
• System.out.print();// CTE
Example:
class Program
{
public static void main(String[] args)
{
System.out.println(“hello world”);
}
}
Output
hello world

You might also like