Now Starting regular Codes Of Java
You Want To practice these Codes in Regular basis
You Want To practice these Codes in Regular basis
// #3 Arrays in Java
public class MyClass {
public static void main(String args[]) {
int arr[] = {2, 3, 6};
//Array declaration and initialization
System.out.println(arr[0]);
//Showing Array First element
}
}
public class MyClass {
public static void main(String args[]) {
int arr[] = {2, 3, 6};
//Array declaration and initialization
System.out.println(arr[0]);
//Showing Array First element
}
}
👍5
//#4 Declaring & iniitializing Array
public class MyClass {
public static void main(String args[]) {
int arr[]; //declaring array
arr = new int[20]; // allocating memory
arr[0]= 55; //iniitializing first element
arr[1]= 33; //initi.... 2nd Element
System.out.println(arr[0]);
}
}
public class MyClass {
public static void main(String args[]) {
int arr[]; //declaring array
arr = new int[20]; // allocating memory
arr[0]= 55; //iniitializing first element
arr[1]= 33; //initi.... 2nd Element
System.out.println(arr[0]);
}
}
👍7
// #5 Atithmetic Operations in Java
public class MyClass {
public static void main(String args[]) {
// declaring variables
int add, sub, div, mul, rem;
// Declaring two varables
int x=4;
int y=2;
// performing Operations
add = x+y; // Addition
sub = x-y; // Subtraction
div = x/y; // Division
mul = x+y; // Multiply
rem= x%y; // reminder
// Showing results
System.out.println("4 + 2 = "+ add);
System.out.println("4 - 2 = "+ sub);
System.out.println("4 * 2 = "+ mul);
System.out.println("4 / 2 = "+ div);
System.out.println("4 % 2 = "+ rem);
}
}
public class MyClass {
public static void main(String args[]) {
// declaring variables
int add, sub, div, mul, rem;
// Declaring two varables
int x=4;
int y=2;
// performing Operations
add = x+y; // Addition
sub = x-y; // Subtraction
div = x/y; // Division
mul = x+y; // Multiply
rem= x%y; // reminder
// Showing results
System.out.println("4 + 2 = "+ add);
System.out.println("4 - 2 = "+ sub);
System.out.println("4 * 2 = "+ mul);
System.out.println("4 / 2 = "+ div);
System.out.println("4 % 2 = "+ rem);
}
}
👍7🤣2
//#6 2 Number Adder(Calculator) from user input
// This for Scan anything entered by user (user inputs)
import java.util.Scanner;
class myClass {
public static void main(String[] args) {
int x,y,Sum;
Scanner s = new Scanner(System.in);
// it will take input from keyboard
System.out.println("Enter 1st Number: ");
x = s.nextInt(); // scanning
System.out.println("Enter 2nd Number: ");
y = s.nextInt(); // scanning
Sum = x+y;
System.out.println("Sum = "+ Sum);
}
}
// This for Scan anything entered by user (user inputs)
import java.util.Scanner;
class myClass {
public static void main(String[] args) {
int x,y,Sum;
Scanner s = new Scanner(System.in);
// it will take input from keyboard
System.out.println("Enter 1st Number: ");
x = s.nextInt(); // scanning
System.out.println("Enter 2nd Number: ");
y = s.nextInt(); // scanning
Sum = x+y;
System.out.println("Sum = "+ Sum);
}
}
👍4
Jiske pass Laptop nhi hai 👇
Mobile best Compiler's
C Compiler Click Here
C++ Compiler Click Here
Python Compiler Click Here
Java Compiler Click Here
Sql Compiler Click Here
Universal Compilers for mobile
Replit (web or app) Click Here
Jdoodle(web or app) Click Here
Programize (web) Search web
For any help Freely Say here
Mobile best Compiler's
C Compiler Click Here
C++ Compiler Click Here
Python Compiler Click Here
Java Compiler Click Here
Sql Compiler Click Here
Universal Compilers for mobile
Replit (web or app) Click Here
Jdoodle(web or app) Click Here
Programize (web) Search web
For any help Freely Say here
👍8