• A.razaq

T2- java introduction

Updated: Jan 20

java is one of the most popular and widely used programming language as a general purpose object oriented language

a popular concept for java is ( WORA ) " write once run anywhere"

java contains Classes and methods

class - a blueprint we use to create objects from.

methods - collection of written statements that we write to preform tasks and return information.

every java program contains at least one class and one Main method


above is an example of a java program

class name - welcome1.

method - public static void main ( String[] args)

below this we write our code which has a task to be preformed

----------------------------------------------------------------------------

braces { } : we use braces {} to group our declarations and statements and methods



public static void main ( String[] args)
{ our code here 

}

Semicolon ; - every statement or instruction ends with a semicolon ;
example

System.out.println("hello"); 

the semicolon ; at the end allows the complier to execute the code and tells the complier where the next line or code begins.


so a typical java program looks like this :


public class example1 
{
public static void main ( String [] args )
{
System.out.println("hello");
}
}

class name - example1

then left brace { main method inside

public static void main ( String [] args )

then another left brace { for our instructions

ends with semicolon ;

then we close out instructions with a right brace }

System.out.println("hello");

after that the class is closed with right brace } which is usually already written


9 views0 comments

Recent Posts

See All