-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
301 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,301 @@ | ||
|
||
public class LoremIpsumJava { | ||
|
||
public static void main(String[] args) { | ||
LoremIpsumJava obj = new LoremIpsumJava(); | ||
obj.method1(); | ||
obj.method2(); | ||
obj.method3(); | ||
obj.method4(); | ||
obj.method5(); | ||
} | ||
|
||
public void method1() { | ||
int a = 0; | ||
for (int i = 0; i < 10; i++) { | ||
a += i; | ||
} | ||
System.out.println(a); | ||
} | ||
|
||
public void method2() { | ||
String lorem = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. "; | ||
lorem += "Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. "; | ||
lorem += "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris "; | ||
lorem += "nisi ut aliquip ex ea commodo consequat."; | ||
System.out.println(lorem); | ||
} | ||
|
||
public void method3() { | ||
double result = 0.0; | ||
for (int i = 1; i <= 100; i++) { | ||
result += Math.sqrt(i); | ||
} | ||
System.out.println(result); | ||
} | ||
|
||
public void method4() { | ||
boolean flag = false; | ||
for (int i = 0; i < 100; i++) { | ||
if (i % 2 == 0) { | ||
flag = !flag; | ||
} | ||
} | ||
System.out.println(flag); | ||
} | ||
|
||
public void method5() { | ||
int sum = 0; | ||
int product = 1; | ||
for (int i = 1; i <= 10; i++) { | ||
sum += i; | ||
product *= i; | ||
} | ||
System.out.println("Sum: " + sum + ", Product: " + product); | ||
} | ||
|
||
public void method6() { | ||
String str = "Lorem ipsum"; | ||
for (int i = 0; i < 50; i++) { | ||
str += " " + i; | ||
} | ||
System.out.println(str); | ||
} | ||
|
||
public void method7() { | ||
int[] arr = new int[10]; | ||
for (int i = 0; i < arr.length; i++) { | ||
arr[i] = i * i; | ||
} | ||
for (int j : arr) { | ||
System.out.println(j); | ||
} | ||
} | ||
|
||
public void method8() { | ||
StringBuilder sb = new StringBuilder(); | ||
for (int i = 0; i < 20; i++) { | ||
sb.append("Lorem ipsum ").append(i).append("\n"); | ||
} | ||
System.out.println(sb.toString()); | ||
} | ||
|
||
public void method9() { | ||
for (int i = 0; i < 100; i++) { | ||
if (i % 10 == 0) { | ||
System.out.println("Multiple of 10: " + i); | ||
} | ||
} | ||
} | ||
|
||
public void method10() { | ||
String[] words = {"Lorem", "ipsum", "dolor", "sit", "amet"}; | ||
for (String word : words) { | ||
System.out.println(word); | ||
} | ||
} | ||
|
||
public void method11() { | ||
int counter = 0; | ||
for (int i = 0; i < 50; i++) { | ||
if (i % 5 == 0) { | ||
counter++; | ||
} | ||
} | ||
System.out.println("Count of multiples of 5: " + counter); | ||
} | ||
|
||
public void method12() { | ||
String sentence = "Lorem ipsum dolor sit amet"; | ||
String[] parts = sentence.split(" "); | ||
for (String part : parts) { | ||
System.out.println(part); | ||
} | ||
} | ||
|
||
public void method13() { | ||
int factorial = 1; | ||
for (int i = 1; i <= 5; i++) { | ||
factorial *= i; | ||
} | ||
System.out.println("Factorial: " + factorial); | ||
} | ||
|
||
public void method14() { | ||
String alphabet = ""; | ||
for (char ch = 'A'; ch <= 'Z'; ch++) { | ||
alphabet += ch; | ||
} | ||
System.out.println(alphabet); | ||
} | ||
|
||
public void method15() { | ||
int[] fib = new int[10]; | ||
fib[0] = 0; | ||
fib[1] = 1; | ||
for (int i = 2; i < fib.length; i++) { | ||
fib[i] = fib[i - 1] + fib[i - 2]; | ||
} | ||
for (int num : fib) { | ||
System.out.println(num); | ||
} | ||
} | ||
|
||
public void method16() { | ||
for (int i = 1; i <= 10; i++) { | ||
if (i % 2 == 0) { | ||
System.out.println(i + " is even"); | ||
} else { | ||
System.out.println(i + " is odd"); | ||
} | ||
} | ||
} | ||
|
||
public void method17() { | ||
String str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; | ||
char[] chars = str.toCharArray(); | ||
for (char c : chars) { | ||
System.out.println(c); | ||
} | ||
} | ||
|
||
public void method18() { | ||
int sum = 0; | ||
for (int i = 0; i < 100; i++) { | ||
sum += i; | ||
} | ||
System.out.println("Sum of first 100 numbers: " + sum); | ||
} | ||
|
||
public void method19() { | ||
String repeated = ""; | ||
for (int i = 0; i < 10; i++) { | ||
repeated += "Lorem ipsum "; | ||
} | ||
System.out.println(repeated); | ||
} | ||
|
||
public void method20() { | ||
String[] colors = {"Red", "Green", "Blue", "Yellow"}; | ||
for (String color : colors) { | ||
System.out.println(color); | ||
} | ||
} | ||
|
||
public void method21() { | ||
int number = 123456; | ||
String numStr = Integer.toString(number); | ||
for (int i = 0; i < numStr.length(); i++) { | ||
System.out.println(numStr.charAt(i)); | ||
} | ||
} | ||
|
||
public void method22() { | ||
int squareSum = 0; | ||
for (int i = 1; i <= 10; i++) { | ||
squareSum += i * i; | ||
} | ||
System.out.println("Sum of squares: " + squareSum); | ||
} | ||
|
||
public void method23() { | ||
String[] animals = {"Cat", "Dog", "Elephant", "Lion"}; | ||
for (String animal : animals) { | ||
System.out.println(animal); | ||
} | ||
} | ||
|
||
public void method24() { | ||
String message = ""; | ||
for (int i = 0; i < 5; i++) { | ||
message += "Hello "; | ||
} | ||
System.out.println(message); | ||
} | ||
|
||
public void method25() { | ||
int cubeSum = 0; | ||
for (int i = 1; i <= 5; i++) { | ||
cubeSum += i * i * i; | ||
} | ||
System.out.println("Sum of cubes: " + cubeSum); | ||
} | ||
|
||
public void method26() { | ||
for (int i = 0; i < 5; i++) { | ||
System.out.println("Iteration " + i); | ||
} | ||
} | ||
|
||
public void method27() { | ||
String text = "Lorem ipsum dolor sit amet"; | ||
for (int i = text.length() - 1; i >= 0; i--) { | ||
System.out.print(text.charAt(i)); | ||
} | ||
System.out.println(); | ||
} | ||
|
||
public void method28() { | ||
for (int i = 0; i < 3; i++) { | ||
for (int j = 0; j < 3; j++) { | ||
System.out.println("i: " + i + ", j: " + j); | ||
} | ||
} | ||
} | ||
|
||
public void method29() { | ||
int number = 1234; | ||
int reverse = 0; | ||
while (number != 0) { | ||
int digit = number % 10; | ||
reverse = reverse * 10 + digit; | ||
number /= 10; | ||
} | ||
System.out.println("Reversed number: " + reverse); | ||
} | ||
|
||
public void method30() { | ||
String sentence = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; | ||
int count = 0; | ||
for (int i = 0; i < sentence.length(); i++) { | ||
if (sentence.charAt(i) == ' ') { | ||
count++; | ||
} | ||
} | ||
System.out.println("Number of spaces: " + count); | ||
} | ||
|
||
public void method31() { | ||
int[][] matrix = new int[3][3]; | ||
for (int i = 0; i < matrix.length; i++) { | ||
for (int j = 0; j < matrix[i].length; j++) { | ||
matrix[i][j] = i + j; | ||
} | ||
} | ||
for (int[] row : matrix) { | ||
for (int val : row) { | ||
System.out.print(val + " "); | ||
} | ||
System.out.println(); | ||
} | ||
} | ||
|
||
public void method32() { | ||
int a = 0, b = 1, sum; | ||
for (int i = 1; i <= 10; i++) { | ||
sum = a + b; | ||
a = b; | ||
b = sum; | ||
System.out.println(sum); | ||
} | ||
} | ||
|
||
public void method33() { | ||
String vowels = "AEIOU"; | ||
for (char ch : vowels.toCharArray()) { | ||
System.out.println(ch); | ||
} | ||
} | ||
|
||
public void method34() { | ||
|