Thursday, January 26, 2023

String practice problems and Solutions

 1.Java Program to Count Number of Duplicate Words in String

2.Java Program to Count Number of Words in Given String

3.Java Program to Count the Number of Occurrences of Substring in a String

4.Java Program to Count the Occurrences of Each Character in String

5.Java Program to Merge two String Arrays  

6.Java Program to Remove Duplicate Words from String 

7.Java Program to Reverse a String(5 ways)

8.Java Program to Reverse Each Word of a String    

9.Java Program to Swap Two Strings      

10.How to Check if the String Contains only Digits         

11.How to Check if the String Contains only Letters  

12.How to Check If the String Contains Only Letters or Digits 

13.Java Program to Check if Input String is Palindrome 

14.Java Program to Find all Permutations of String

15.How to Remove or Trim All White Spaces from a String in Java

16.How to Remove Leading and Trailing White Space From a String in Java

17.Java Program to Count Duplicate Characters in a String

18.Remove Character from String in Java (Java 8)

19.Java Program to Count Vowels and Consonants in a String (Java 8)

20>  4 Ways to Find First Non-Repeated Character in String in Java

Wednesday, January 18, 2023

Array practice problems and Solutions

1D Array-related problems.

1. Write a program to print a string using an array.

2. Write a program to find the sum of negative and positive integers.

3. Write a program to find the sum of N numbers in an array

4. Write a program to find the smallest element in the array

5. Write a program to find the largest element in the array

6. Write a program to find the 2nd smallest element in the array

7. Write a program to find the 2nd largest element in the array

8. Write a program to Print the Average of Numbers in array at an even position

9. Write a program to Print the Average of Numbers in array at an odd position

10. Write a program to print array elements in reverse order.

11. Write a program to print array elements in reverse order using the swapping method.

12. Write a program to separate even and odd numbers in an array.

13. Write a program to print the frequency of all numbers in an array.

14. Write a program to print the most occurring elements.

15. Write a program to separate even and odd position numbers in an array.

16. Write a program to separate positive and negative numbers in an array.

17. Write a program to print lists of occurring elements in an array.

18. Write a program to insert an element into an array at a specified position

19. Write a program to delete a specified integer in an array

20. Write a program to search a specified integer in an array

21. Write a program to find the array type

22. Write a program to sort the elements of an array

23. Write a program to count distinct elements of an array

24. Write a program to remove duplicate elements in an array

25. Write a program to check if two arrays are the same or not.

26. Write a program to check if one array is a subset of another array or not.

27. Write a Program to Find the index of an element in an array.

28. Write a Program to Sort an array in Descending order.

29. Write a Program to Merge two unsorted arrays of different lengths.

30. Write a Program to remove an element from an array by index.

31. Write a Program to Move all zeros to the end of an Array.

32. Write a Program to Move all zeros to the Start of an Array.

33. Write a Program to Find the mean and median of an unsorted array.

34. Write a Program to Find the maximum product of 3 numbers in an array.

35. Write a Program to Find missing numbers in an array.


Matrix or 2D Array-related problems.

1. Write a Program to read and display a Matrix.

2. Write a Program to Find the sum of all elements in a 2d array or Matrix.

3. Write a Program to find the addition of two matrices.

4. Write a Program to find the multiplication of two matrices.

5. Write a Program to the Subtraction of two matrices.

6. Write a Program to print the square of each element of the 2d array or matrix.

7. Write a Program to accept two matrices and check whether they are equal or Not.

8. Write a Program to find whether the given is the matrix is diagonal or not.

9. Write a Program to find the sum of all diagonal elements of a matrix.

10. Write a Program to find the maximum element in the matrix.

11. Write a Program to find the minimum element in the matrix.


Friday, September 30, 2022

Java Program1

 Program 1-Write a program to print your name in output screen

class Test

{

public static void main(String ar[])

{

System.out.println("Lakshya");

}

}

--------------------------------------------------------------------------------------------------------------------------------

for Compilation 

 javac Test.java

for run 

java Test

--------------------------------------------------------------------------------------------------------------------------------