here our first program hello world, to write this program we need to get in eclipse and it starts with eclipse ide asks Eclipse IDE uses the workspace directory to store its preferences and development artifacts.
it shows workspace: /home/your name/eclipse-workspace
we open the in the order like project–>package –>class
its nothing like windows file creation,
Drive–>folder–>file
now we start to write “hell world”. The eclipse perform like a word editor ,it helps the programmer to write a program in a simple manner and gives information bit by bit we type the program and give the correction like typing assistant. simultaneously compilation run in background and process the result. before we start to write program first we understand that java is case sensitive.
public class MyClass{
public static void main(String[] args){
System.out.println(“Hello World”);
}
}
in above MyClass is a class name and it should be follw below rules.
it should be meaningful , it shouldn’t be a verb ,there in no space between the letters, the first letter must be capital letter, first letter should not be a number, the class must be camel case example:- MyFirstProgram
public is a Java keyword which declares a member’s access as public. Public members are visible to all other classes. This means that any other class can access a public field or method. Further, other classes can modify public fields unless the field is declared as final.
public class classname
- A static method belongs to the class rather than object of a class.
- A static method invoked without the need for creating an instance of a class.
- static method can access static data member and can change the value of it.
- A static method can be accessed just using the name of a class dot static name …
- If you want to use non-static fields of a class, you must use a non-static method.
- static :- data stored only once it doesnt meant constant
void is a return type in java. It signifies that a method returns nothing, as implied by its literal meaning. For example, we write: public static void main(String args[]) It shows that return type of the function called ‘main’ has the return type void, hence it cannot return any number or string.
main is method that perform the operation in to the paranthesis {}
method{
method body or method definition
}
method definition: it is used to perform the operation on the content in between the brackets, we give it to perform required action.
system.out.println(“Hello World”)
it print the (content) in output display.here the println is like main method, but it used to print the data in between the bracket to output display.
in future blogs we see the operators,maths operations, and so on. thank for reading.
reference sites:www.stackoverflow.com