Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Kuppiya Module 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Welcome to 20th java sinhala ය

What is Programming language.?

Set of instructions to obtaining output from the computer

Programming Languages

High Level Programming Languages Low Level Programming Languages


High Human Readability Low Human Readablity
java

JDK - Java Development Kit

JRE - Java Runtime Environment

JVM - Java Virtual Machine

javac java

Example.java Compile Execute


Example.class Machine Code
Compiler JVM

Source Code
Byte Code
.java
.class
Day - 1
Variable
int number = 10;

10

number

Data Types

Primitive Data Types Non - Primitive Data Type


Reference Data Type
byte ((-27) - (27 - 1))
short ((-215) - (215 - 1)) String
int ((-231) - (231 - 1))
long ((-263) - (263 - 1))
float (Floating Point Numbers) class Example{
double (Floating Point Numbers) public static void main(String args[]){
char (Single Charactor, Unicodes, ASCII Codes) // Numbers
byte b = 100;
boolean (true/ false) short s = 200;
int i = 300;
long l = 400;

// Floating Points
float f = 10.5F;
double d = 10.5;

//Single Charactor
char c = 'A';
char c1 = '\u0048';
char c2 = 87;

// True or False
boolean bool = true;

// Text
String str = "Hello Java";
}
}

byte short int long float double

char
class Example{
Operators public static void main(String args[]){
+ Addition int number1 = 20;
- Subtraction int number2 = 7;
/ Devision
// Addition
* Multiplication int answer = number1 + number2;
% Modulu
++ Increment // Subtraction
answer = number1 - number2;
-- Decrement
// Devision
double answer2 = (double)number1 / number2;

// Multiplication
X++ - Post Fix answer = number1 * number2;
++X - PreFix
// Modulu
int answer = number1 % number2;

// Increment --> number1 = number1 + 1;


number1++;

// Decrement --> number2 = number2 - 1;


number2--;

int x = 10;

System.out.println(x); // 10
System.out.println(x++); // 10 PostFix
System.out.println(x); // 11
System.out.println(++x); // 12 PreFix
}
}

Scanner

import java.util.*;

class Example{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter your number : ");
int number = input.nextInt();

System.out.println();

System.out.println("Your Number is : " + number);


}
}

import java.util.*;

class Example{
public static void main(String args[]){
Scanner input = new Scanner(System.in);
System.out.print("Enter Number 1 : ");
int number1 = input.nextInt();

System.out.print("Enter Number 2 : ");


int number2 = input.nextInt();

int total = number1 + number2;

System.out.println();

System.out.println("Total : " + total);


}
}

You might also like