JAVA PROGRAMMING
4.93K subscribers
233 photos
186 files
91 links
Hello! I am @imabhi3030 and welcome to the Coding channel! Here we can learn all things related to coding and improve our skills. I am always present to help you. If you need any kind of assistance, just let me know! 😊
Download Telegram
Program to print hello world in java

public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
Program to add two numbers
-------------------------------------------------
Program:

import java.util.Scanner;

public class AddTwoNumbers {
public static void main(String[] args) {
// Create a Scanner object to read input from the user
Scanner scanner = new Scanner(System.in);

System.out.print("Enter the first number: ");
// Read the first number from the user
double num

#basicprograms
Program to add two numbers by accepting input from the user:
----------------------------------------------------
Program:

import java.util.Scanner;

public class AddTwoNumbers {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// Prompt the user to enter the first number
System.out.print("Enter the first number: ");
int num1 = input.nextInt();

// Prompt the user to enter the second number
System.out.print("Enter the second number: ");
int num2 = input.nextInt();

// Add the two numbers
int sum = num1 + num2;

// Display the result
System.out.println("The sum of " + num1 + " and " + num2 + " is " + sum);
}
}

----------------------------------------------------
#basicprograms
👍1
here's a sample Java program that computes the factorial of a given integer using recursion:

public class FactorialExample {
public static void main(String[] args) {
int num = 5; // the number whose factorial is to be found
int factorial = calculateFactorial(num);

System.out.println("The factorial of " + num + " is " + factorial);
}

public static int calculateFactorial(int num) {
if (num == 0) {
return 1;
} else {
return num * calculateFactorial(num - 1);
}
}
}
👍3
Program with use of switch case to find a months

public class Example{
public static void main(String args[]){
int month= 7;

switch(month){
case 1 :
System.out.println("january");
break;
case 2:
System.out.println("february");
break;
case 3:
System.out.println("march");
break;
case 4:
System.out.println("april");
break;
case 5:
System.out.println("may");
break;
case 6:
System.out.println("june");
break;
case 7:
System.out.println("july");
break;
case 8:
System.out.println("august");
break;
case 9:
System.out.println("september");
break;
case 10:
System.out.println("October");
break;
case 11:
System.out.println("november");
break;
case 12:
System.out.println("december");
break;
default:
System.out.println("not valid");
}
}
}

Output: july
👍3🔥1
Subscribe our channel for termux hacking,python animation,coding,html ,telegram bot tips & trick related - 👉 https://youtube.com/@CODEBOMBS Subscribe our channel for termux hacking, designing, tips & trick, bot making related - 👉 https://youtube.com/@TECHINDNN
//#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]);
  }
}
❤2
//#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]);
  }
}
❤4👍1
🔰 join ᴏᴜʀ ᴀʟʟ ᴄʜᴀɴɴᴇʟs for coding 🔰

ᴛᴇʀᴍᴜx ʜᴀᴄᴋɪɴɢ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴛᴇʀᴍᴜx ᴄᴏᴍᴍᴀɴᴅ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴛᴇʀᴍᴜx ᴛʀɪᴄᴋs ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴘʜᴘ ʟᴀɴɢᴜᴀɢᴇs ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴄ ᴘʀᴏɢʀᴀᴍᴍɪɴɢ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴄ++ ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴄ# ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴊᴀᴠᴀ ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴄss ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴘʏᴛʜᴏɴ ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴛʏᴘᴇsᴄʀɪᴘᴛ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ᴊᴀᴠᴀsᴄʀɪᴘᴛ ᴄʟɪᴄᴋ ʜᴇʀᴇ
ʜᴛᴍʟ ʟᴀɴɢᴜᴀɢᴇ ᴄʟɪᴄᴋ ʜᴇʀᴇ
// #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);
}
}
//#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);
}
}
❤2🔥2
Data structures short notes
❤5