// 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);
}
}👍1
👍1
// Factotial from recursion in java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter Number: " );
int n = s.nextInt();
if(n>26)
System.out.print("Please enter number less than 25\n" );
else{
System.out.println("Showing factorial for "+ n + " Number" );
System.out.print("\n" +Main.f(n));
}
}
// Factorial value calculation + series printing
static long f(long n){
if (n==1){
System.out.print(n);
return n;
}
else{
System.out.print(n + " * ");
return n*f(n-1);
}
}
} // @Java_Codes_Pro
👍4
Ab aap log apna khud ka Compiler bot bana sakte hain easily 🥳🥳🔥
Apne manpasand name aur username se
Create your own
By using @CloneCompiler_bot
See full details: Click Here
Apne manpasand name aur username se
Create your own
By using @CloneCompiler_bot
See full details: Click Here
👍2
// Run and see bharateey flag clolours
public class Main{
public static void main(String[] args){
System.out.println(" Ye Hain\n bharat ke flag\n\"ke colours\"");
}
}You can practice your codes in
@codeCompiler_bot
It supports short coding 👇
For upper part of java you can simply write
And for lower part
Then in middle you can write java code
But one thing more
You don't need to write big print statement like
Just write
And then your code without parenthesis
Full example
You can run this code on @codeCompiler_bot using
/jv command
You can convert this code in real java code by using
/rjv command
Here is more short code example
See practical example 👇
t.me/LogicB_Support/11005
Is it easy give reactions or ask questions 👇
@codeCompiler_bot
It supports short coding 👇
For upper part of java you can simply write
"Start"
And for lower part
"End"
Then in middle you can write java code
But one thing more
You don't need to write big print statement like
System.out.println();
Just write
pt
And then your code without parenthesis
Full example
"Start"
Pt "hi this is mine short java"
"End"
You can run this code on @codeCompiler_bot using
/jv command
You can convert this code in real java code by using
/rjv command
Here is more short code example
import java.util.Scanner;
"Start"
Scanner scanner = new Scanner(System.in);
Pt"Enter an integer: "
int number = scanner.nextInt();
Pt"You entered: " + number
scanner.close();
"End"
See practical example 👇
t.me/LogicB_Support/11005
Is it easy give reactions or ask questions 👇
👍2🥰1
It's discussion group is now public
Join @java_group_pro
Join @java_group_pro
Select your group/channel/service
t.me/Sid_info/69
t.me/Sid_info/69
// 1. length()
public class StringLengthExample {
public static void main(String[] args) {
String str = "Hello, World!";
int length = str.length();
System.out.println("Length of the string: " + length);
}
}👍1
// 2. toUpperCase()
public class UpperCaseExample {
public static void main(String[] args) {
String str = "Hello, World!";
String upperCaseString = str.toUpperCase();
System.out.println("Uppercase string: " + upperCaseString);
}
}// 3. toLowerCase()
public class LowerCaseExample {
public static void main(String[] args) {
String str = "Hello, World!";
String lowerCaseString = str.toLowerCase();
System.out.println("Lowercase string: " + lowerCaseString);
}
}// 4. equals()
public class StringEqualityExample {
public static void main(String[] args) {
String str1 = "hello";
String str2 = "HELLO";
boolean isEqual = str1.equals(str2);
System.out.println("Are strings equal? " + isEqual);
}
}// 5. substring()
public class SubstringExample {
public static void main(String[] args) {
String str = "Hello, World!";
String substring = str.substring(7);
System.out.println("Substring from index 7: " + substring);
}
}// 6. indexOf()
public class IndexOfExample {
public static void main(String[] args) {
String str = "Hello, World!";
int index = str.indexOf('o');
System.out.println("Index of 'o': " + index);
}
}👍1
// 7. replace()
public class ReplaceExample {
public static void main(String[] args) {
String str = "Hello, World!";
String replacedString = str.replace('l', 'z');
System.out.println("String after replacement: " + replacedString);
}
}❤1
// 8. contains()
public class ContainsExample {
public static void main(String[] args) {
String str = "Hello, World!";
boolean contains = str.contains("World");
System.out.println("Does the string contain 'World'? " + contains);
}
}// 9. trim()
public class TrimExample {
public static void main(String[] args) {
String spacedString = " Some spaces ";
String trimmedString = spacedString.trim();
System.out.println("Trimmed string: '" + trimmedString + "'");
}
}// 10. isEmpty()
public class IsEmptyExample {
public static void main(String[] args) {
String emptyString = "";
boolean isEmpty = emptyString.isEmpty();
System.out.println("Is the string empty? " + isEmpty);
}
}