Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Java Programs

Basic programs:

1.palindrome of a number

2.Palindrome of a String

3.Fibnoci series

4.Factorial program

5.Program to print prime numbers

6.Program to print Even and Odd numbers

7.Program for Square Root

8.write a program to convert Integer to binary

9.Write a program for power root function

10. write a program to Reverse a number

11. Write a program to print different number patterns

12. Write a program to print different Star patterns

13. write a program to print cube of a number

String programs:

14.write a program to count total no of characters in a string

string="thisisjavaclass";

15.write a program to count uppercase and lowercase in a string

string="ThiSisJavaclaSs";

16.write a program to count uppercase, lowercase,digits and special characters in a string

string="ThiSis@Java*c#laSs345";

17.write a program to count vowels and consonants in a string using scanner class.

string="Helloworld";

18.write a program to Reverse a string

string="thisisjavaclass";
19.write a program to Reverse each word in a string

string="this is a java class";

output="sihT si a avaj ssalc";

20. write a program to find no of spaces and words in a string.

string="this isjava class";

21.write a program to capitalize the first letter of each word in a string.

22.write a program to count duplicates in a string.

23.write a program to find largest word and smallest word.

string="this is a java program";

24.write a program to find maximum repeated characters in a string.

string="thisisajavaprogram";

25. string s ="ihubjava";

string s1="qualitythought";

write a program to remove repeated letters of string s to s1.

26.write a program to check whether each word in a string is palindrome or not.

string="madam and mom are friends";

27.write a program to swap two strings.

28.write a program to retain space places in a string.

string="this is a java program";

output="marg or pava jsishit";

29.Replace string "java1234" with "javaprogramming"

30.Replace word 47 with fourseven.

31. write a program to covert string to int.

Array programs:

32.write a program to find duplicates in an array.

int[] a ={7,5,3,3,2,4,5,7,9}

33. write a program to find 3rd highest number in an array using sort functionality and without using
sort functionality.

int[] a ={70,5,30,3,2,4,15,7,9}
34. write a program to swap two numbers with and without using third variable.

35.write a program to remove duplicates from an array.

36.write a program to count no of odd and even numbers in an array.

37.write a program to get the sum of odd and even numbers in an array.

38.write a program to find most occurring number in an array.

int[] a ={70,5,30,3,2,4,15,70,5,5,30,5,6,5}

39.write a program to find total uppercase and lowercase letters in each word in an array.

string[]s={"tHiS","Is","jAVa","Class"}

40.write a program to find largest num in an array.

41.write a program to find smallest num in an array.

Switch programs:
42. Day number to Day Name

43. Day name to Day number

44. Month number to Month name

45.Month name to month number

Collections Programs:
46.Write a java program to create a array list and add elements and print them

47.Write a javaprogram to print a array list in Reverse Order with and With out using Reverse Order

48. Program to remove Specific element (eg-23) in Array list

array list = [18,45,88,9,23,45,67,18].

49.Remove Duplicates from array list (With and With out Linked hash set)

array list = [18,45,8,8,9,23,8,45,67,1,8].

50.Program to replace 58 with 85 in the below array list and print updated array list

array list = [78,58,43,78,90,12].

51. Remove class element from this arraylist.

array list = ["java","class","at","ihub"].

52.Extract some of the elements from the main arraylist and print extracted elements(use
arrayfunctions)

array list = [78,58,43,78,90,12].


output: = [78,58,43,].

53. Extract some of the elements from the main arraylist and print extracted elements(use
arrayfunctions)

array list = ["geeta","seeta","shyam","ram"].

output: = ["geeta","seeta"].

HashMap Programs:
54. write a program to print count of no of duplicates of repeated characters using hashmap.

string="wearestartingselenium"

55. write a program to print duplicate vowels in the string.

string="wearestartingseleniumtommorow"

You might also like