TechnolamrorJava Programs Designed By : Rajendra Lamror Contents Java Programs.............................................................................................................................................................................. 1 1. Simple Java Program. ....................................................................................................................................................... 4 2. Print Integer in java ............................................................................................................................................................ 4 3. Command Line Argument ................................................................................................................................................ 4 4. How to get Using input using Scanner Program in java ........................................................................................ 5 5. How to convert Fahrenheit to Celsius Program in java ....................................................................................... 5 rd 6. How to swap 2 no using 3 variable Program in java ............................................................................................ 6 7. How to swap 2 no without using 3 variable Program in java ............................................................................. 6 8. How to add two number Program in java ................................................................................................................... 7 9. Find Largest no in java Program ................................................................................................................................... 8 rd 10. If Else clause in java ..................................................................................................................................................... 8 11. If Else clause in java- Program 2 ............................................................................................................................... 9 12. Nested If Else clause in java ....................................................................................................................................... 9 13. How to check Odd and Even Number in java. ...................................................................................................... 10 14. Find factorial for given no Program in Java ......................................................................................................... 10 15. How to complete 2 string in Java program .......................................................................................................... 11 16. Simple For Loop Program in Java ......................................................................................................................... 12 17. Print Star console using Loop ................................................................................................................................. 12 18. Print Star console using Loop ................................................................................................................................. 13 19. While loop Program in java ....................................................................................................................................... 13 20. Print Reverse number in java program ................................................................................................................. 14 21. While loop using break Program in java .............................................................................................................. 14 22. While loop using break and continue Program in java ...................................................................................... 15 23. Print all alphabet using for loop Program in java................................................................................................ 15 24. Enhance loop in java Program ................................................................................................................................ 16 25. Print Multiplication table Program in java ............................................................................................................ 16 26. Print prime no Program in java ............................................................................................................................... 17 27. Check no is Armstrong or not in java Program ................................................................................................. 18 28. Print Floyd’s Triangle in java Program ................................................................................................................ 19 29. Find All substring of string in java Program ........................................................................................................ 19 www.TechnoLamror.com Need More PDF Summit Here Technolamror 30. Print reverse string in java Program ..................................................................................................................... 20 31. Check Given No is palindrome or Not in java Program .................................................................................... 21 32. How to add two matrix in java Program ................................................................................................................. 22 33. How to multiply two matrix in java Program......................................................................................................... 23 34. How to get transpose of matrix in java Program ................................................................................................ 24 35. How to compare 2 string in java Program ............................................................................................................ 25 36. How to string width with specific char in java Program ................................................................................... 25 37. How to use indesOf() in java Program .................................................................................................................. 25 38. How to replace string with another string in java Program ............................................................................. 26 39. How to split string in java Program ........................................................................................................................ 26 40. How to remove space in string both end in java Program ................................................................................ 26 41. How to convert all char in string lower case in java Program ......................................................................... 26 42. How to create method in java Program ................................................................................................................ 27 43. Find Length, Concatenate and Replace String in Java Program ................................................................... 27 44. How Static block working in java Program ........................................................................................................... 28 45. Difference between Static and Instance method working in java Program ................................................. 28 46. How to create Multiple class in java Program ..................................................................................................... 29 47. How to create constructor in java Program ......................................................................................................... 29 48. How to create constructor overloading in java Program ................................................................................. 30 49. Exception Handling java Program........................................................................................................................... 30 50. How to throw exception in java Program ............................................................................................................. 31 51. Advantage of Finally in Exception Handling java Program ............................................................................. 31 52. How to create Interface in java Program .............................................................................................................. 32 53. How to print date and time in java Program ........................................................................................................ 32 54. How to SQL Date in java Program .......................................................................................................................... 33 55. How to Date format in java Program .................................................................................................................... 33 56. How to Generate random number in java Program ........................................................................................... 34 57. How perform garbage collection in java Program ............................................................................................. 34 58. How to get own IP Address in java Program ....................................................................................................... 34 59. How to open notepad in java Program.................................................................................................................. 35 60. Leaner search Program in java ............................................................................................................................... 35 61. Binary search Program in java ................................................................................................................................ 36 62. Bubble sort Program in java .................................................................................................................................... 37 63. How to connect Database using java Program .................................................................................................... 37 64. How to insert data in table using JDBC in java Program ................................................................................ 38 65. How to insert image using JDBC in java Program............................................................................................ 38 66. How to execute Procedure in JDBC in java Program....................................................................................... 39 www.TechnoLamror.com Need More PDF Summit Here Technolamror 67. How to check Regular expression in java Program .......................................................................................... 39 68. How to create Multithreading program in java ..................................................................................................... 39 69. How to join thread in java program ....................................................................................................................... 40 70. How to write data in text file using java program ............................................................................................... 40 71. How to read data from text file using java program .......................................................................................... 40 72. How to get URL of site using java Programs ....................................................................................................... 41 73. How to get IP address from site URL using java program ................................................................................ 41 74. How to create AWT program in java ....................................................................................................................... 41 75. How to add lable in AWT program in java ............................................................................................................ 42 76. How to add text area program in java .................................................................................................................... 42 77. How to dropdown in AWT program in java ........................................................................................................... 42 78. How to create Swing program in java ................................................................................................................... 43 79. How to add checkbox in Swing program in java ................................................................................................. 43 80. How to convert string to integer in java program .............................................................................................. 44 81. How to convert integer to string in java program .............................................................................................. 44 82. How to convert string to long in java ..................................................................................................................... 44 83. How to convert string to float in java ..................................................................................................................... 44 84. How to convert string to double in java program................................................................................................ 44 85. How to convert string to date in java program ................................................................................................... 45 86. Create ArrayList program in java ......................................................................................................................... 45 87. How to create LinkedList program in java ............................................................................................................ 46 88. How to ArrayList using list interface program in java ....................................................................................... 46 89. How to create Hashset program in java ................................................................................................................. 47 90. How to create LinkedHashSet program in java ................................................................................................... 47 91. How to create TreeSet program in java.................................................................................................................. 48 92. How to create PriorityQueue program in java ...................................................................................................... 48 93. How to create HashMap using map interface program in java ........................................................................ 49 94. How to create LinkedHashMap program in java ................................................................................................. 49 95. How to create TreeMap program in java ................................................................................................................ 49 96. How to create Hashtable program in java ............................................................................................................. 50 97. How to create Array program in java ...................................................................................................................... 50 98. How to create Multidimensional array program in java ..................................................................................... 50 99. How to create Find Factorial No using Recursion Program in java .............................................................. 51 100. How to create Method Overriding program in java ............................................................................................. 51 www.TechnoLamror.com Need More PDF Summit Here Technolamror 1. Simple Java Program class HelloWorld { public static void main(String args[]) { System.out.println("Hello World by Technolamror"); } } 2. Print Integer in java class Integers { public static void main(String[] arguments) { int c; //declaring a variable /* Using for loop to repeat instruction execution */ for (c = 1; c <= 10; c++) { System.out.println(c); } } } 3. Command Line Argument in java class Arguments { public static void main(String[] args) { for (String t: args) { System.out.println(t); } } } www.TechnoLamror.com Need More PDF Summit Here Technolamror 4. How to get Using input using Scanner Program in java import java.util.Scanner; class GetInputFromUser { public static void main(String args[]) { int a; float b; String s; Scanner in = new Scanner(System.in); System.out.println("Enter a string"); s = in.nextLine(); System.out.println("You entered string "+s); System.out.println("Enter an integer"); a = in.nextInt(); System.out.println("You entered integer "+a); System.out.println("Enter a float"); b = in.nextFloat(); System.out.println("You entered float "+b); } } 5. How to convert Fahrenheit to Celsius Program in java import java.util.*; class FahrenheitToCelsius { public static void main(String[] args) { float temperatue; Scanner in = new Scanner(System.in); System.out.println("Enter temperatue in Fahrenheit"); temperatue = in.nextInt(); temperatue = ((temperatue - 32)*5)/9; System.out.println("Temperatue in Celsius = " + temperatue); } } www.TechnoLamror.com Need More PDF Summit Here Technolamror 6. temp.println("Before Swapping\nx = "+x+"\ny = "+y). x = in.Scanner. y. class SwapNumbers { public static void main(String args[]) { int x.println("Enter x and y").out.in).nextInt().util.nextInt().in).com Need More PDF Summit Here .TechnoLamror. y = temp.out. y = in. System. System.nextInt(). Scanner in = new Scanner(System. x = in.util.nextInt().out. class SwapNumbers { public static void main(String args[]) { int x. System.out.println("Enter x and y"). } } 7. Scanner in = new Scanner(System. y. www.Scanner. System. x = y. System. temp = x. How to swap 2 no without using 3rd variable Program in java import java.println("Before Swapping\nx = "+x+"\ny = "+y).println("After Swapping\nx = "+x+"\ny = "+y). y = in.out. How to swap 2 no using 3rd variable Program in java import java. y.println("Enter two integers to calculate their sum "). BigInteger sum. y = x . System. System.y.com Need More PDF Summit Here . System. x = x . How to add two number Program in java import java. class AddNumbers { public static void main(String args[]) { int x. number2. } } //For Large Number import java. BigInteger first = new BigInteger(number1).math.nextInt().println("Result of addition = " + sum).out. Scanner in = new Scanner(System.add(second). y = in.util. number1 = in.Scanner. import java.println("Enter second large number").out. BigInteger second = new BigInteger(number2). z.Technolamror x = x + y. class AddingLargeNumbers { public static void main(String[] args) { String number1. System. sum = first.in). Scanner in = new Scanner(System. x = in. } www.println("Enter first large number").out.out.y.TechnoLamror. System.nextInt().nextLine().println("After Swapping\nx = "+x+"\ny = "+y). number2 = in.out. System. } } 8.println("Sum of entered integers = "+z). z = x + y.BigInteger.util.out.nextLine().Scanner.in). println("Entered numbers are not distinct.out.println("Second number is largest.out. if (learning) { System.out.nextInt(). Find Largest no in java Program import java.com Need More PDF Summit Here .println("Third number is largest. else if ( y > x && y > z ) System. } else { System. z = in. y.Scanner.TechnoLamror.println("Enter three integers ").Technolamror } 9. y = in. if ( x > y && x > z ) System.").println("Java programmer"). } } 10. x = in.out. class LargestOfThreeNumbers { public static void main(String args[]) { int x.")."). else if ( z > x && z > y ) System.nextInt().util.out. } } } www. z.nextInt().out.out."). else System.in). Scanner in = new Scanner(System.println("What are you doing here?"). System.println("First number is largest. If Else clause in java class Condition { public static void main(String[] args) { boolean learning = true. "). } } } 12. if (marksObtained >= passingMarks) { System.com Need More PDF Summit Here .nextInt(). System.out. Nested If Else clause in java import java.println("Input marks scored by you"). passingMarks = 40.out.println("Unfortunately you failed to pass the exam."). Scanner input = new Scanner(System. If Else clause in java. passingMarks. Scanner input = new Scanner(System. marksObtained = input.println("You passed the exam.println("Input marks scored by you"). System.in).out.nextInt(). class NestedIfElse { public static void main(String[] args) { int marksObtained.util.Program 2 // If else in Java code import java. www. } else { System.Technolamror 11. marksObtained = input. if (marksObtained >= passingMarks) { if (marksObtained > 90) grade = 'A'.out. char grade.in).TechnoLamror. class IfElse { public static void main(String[] args) { int marksObtained.Scanner.Scanner.util. passingMarks = 40. passingMarks. "). Find factorial for given no Program in Java import java.out.nextInt(). (marksObtained > 60) = 'C'.in). class Factorial { public static void main(String args[]) { int n. if ( x % 2 == 0 ) System.println("You failed and your grade is " + grade).out.out. } } } 13.com Need More PDF Summit Here .Scanner.println("You entered an odd number. else System.Scanner.nextInt().out. c. System.println("Enter an integer to check if it is odd or even ").out.println("You passed the exam and your grade is " + grade). Scanner in = new Scanner(System."). Scanner in = new Scanner(System. System. fact = 1.out. How to check Odd and Even Number in java. = 'D'. System.util.Technolamror else if grade else if grade else grade (marksObtained > 75) = 'B'. n = in. System. x = in.println("Enter an integer to calculate it's factorial"). } } 14. import java.util. } else { grade = 'F'.println("You entered an even number.in). class OddOrEven { public static void main(String args[]) { int x.TechnoLamror. www. System.in). } System. How to complete 2 string in Java program import java. c.println("Input an integer").util.out.println("Number should be non-negative.out.multiply(inc). c <= n . else { for ( c = 1 . c <= n.out. s2.nextInt(). for large No class BigFactorial { public static void main(String args[]) { int n. } } 15.com Need More PDF Summit Here .out. n = input.println(n + "! = " + fact). Scanner in = new Scanner(System. c++) { fact = fact.out. for (c = 1. www.Technolamror if ( n < 0 ) System. s1 = in.println("Factorial of "+n+" is = "+fact). System.math.TechnoLamror. BigInteger fact = new BigInteger("1").BigInteger.add(BigInteger.Scanner. Scanner input = new Scanner(System. class CompareStrings { public static void main(String args[]) { String s1. c++ ) fact = fact*c.Scanner. System. import java.ONE). inc = inc."). BigInteger inc = new BigInteger("1").nextLine().println("Enter the first string").in).util. } } } //Calculate factorial import java. out.println("Both strings are equal. Print Star console using Loop class Stars { public static void main(String[] args) { int row. for (row = 1. for (c = 1.print("*").out. } } 16.com Need More PDF Summit Here . c++) { System. row++) { for(numberOfStars = 1.out. Simple For Loop Program in Java //Java for loop program class ForLoop { public static void main(String[] args) { int c.out.compareTo(s2) < 0 ) System. else if ( s1.out.println("First string is greater than second.out.Technolamror System. c <= 10. } } } 17. s2 = in. numberOfStars.").println(). } System. else System.println(c).nextLine(). numberOfStars <= row.").println("First string is smaller than second.TechnoLamror. row <= 10.compareTo(s2) > 0 ) System. numberOfStars++) { System.out.println("Enter the second string"). if ( s1. // Go to next line } } } www."). Print Star console using Loop class Stars { public static void main(String[] args) { int row.com Need More PDF Summit Here .out.in). Scanner input = new Scanner(System. numberOfStars <= row. System.println().TechnoLamror.out. } System. for (row = 1. row++) { for(numberOfStars = 1.Technolamror 18. class WhileLoop { public static void main(String[] args) { int n.Scanner. while ((n = input.println("Input an integer"). row <= 10.out. numberOfStars. // Go to next line } } } 19. } System.println("You entered " + n).println("Out of loop"). } www. While loop Program in java import java.out. System.print("*"). numberOfStars++) { System.println("Input an integer").out.out.nextInt()) != 0) { System.util. System. } System.println("You entered " + n). } System. n = input.nextInt(). class ReverseNumber { public static void main(String args[]) { int n. while (true) { System. Scanner input = new Scanner(System. n = n/10.in). while( n != 0 ) { reverse = reverse * 10.in). reverse = reverse + n%10.out.Technolamror } 20.TechnoLamror. reverse = 0.util.out.println("Enter the number to reverse"). } } 21.com Need More PDF Summit Here . Scanner in = new Scanner(System. Print Reverse number in java program import java.out.nextInt().Scanner. if (n == 0) { break. n = in. class BreakWhileLoop { public static void main(String[] args) { int n. } } } www. While loop using break Program in java import java.Scanner.util.println("Input an integer").println("Reverse of entered number is "+reverse).out. out.TechnoLamror. while (true) { System. n = input.util.println("You entered " + n). Scanner input = new Scanner(System.in). for( ch = 'a' . if (n != 0) { System. } } } } 23.com Need More PDF Summit Here .out.out.println(ch).Scanner. } else { break.nextInt(). class BreakContinueWhileLoop { public static void main(String[] args) { int n.println("Input an integer"). ch++ ) System. } } www. continue. Print all alphabet using for loop Program in java class Alphabets { public static void main(String args[]) { char ch. While loop using break and continue Program in java import java.Technolamror 22. ch <= 'z' . out. 3.println(sample). } } } //For String class EnhancedForLoop { public static void main(String[] args) { String languages[] = { "C".util. Enhance loop in java Program class EnhancedForLoop { public static void main(String[] args) { int primes[] = { 2.in). System. c. 5. 29}. 11. c. c++ ) System. class Tables { public static void main(String args[]) { int a.Scanner.Technolamror 24.out.util. Print Multiplication table Program in java import java.println(t). } } //For Any Number import java.println("Multiplication table of "+n+" is :-"). c <= 10 . 13. 17.out.com Need More PDF Summit Here .out. "Python". n = in. for (int t: primes) { System.Scanner.println("Enter an integer to print it's multiplication table").out. } } } 25.TechnoLamror.println(n+"*"+c+" = "+(n*c)). b. 23. class MultiplicationTable { public static void main(String args[]) { int n. 7. Scanner in = new Scanner(System. "Ruby"}. "C++".nextInt(). for (String sample: languages) { System. System. for ( c = 1 . 19. d. "Java". www. } www.out.println(num). Scanner in = new Scanner(System. j++ ) { if ( num%j == 0 ) { status = 0.out.util.out.println(c+"*"+d+" = "+(c*d)). System.nextInt().com Need More PDF Summit Here .out. status = 1.nextInt().println("Enter the number of prime numbers you want"). d++) { System.out. b = in. } } } } 26.out. j <= Math. count++.in). Scanner in = new Scanner(System. } for ( int count = 2 .println("Multiplication table of "+c). c++) { System. num = 3.nextInt(). n = in.println("Enter range of numbers to print their multiplication table").sqrt(num) . c <= b. ) { for ( int j = 2 . a = in.println("First "+n+" prime numbers are :-"). if (n >= 1) { System.*. count <=n . d <= 10. } } if ( status != 0 ) { System.Technolamror System. System. for (c = a.TechnoLamror.println(2). break. Print prime no Program in java import java.in). for (d = 1.out. class PrimeNumbers { public static void main(String args[]) { int n. "). c <= r.out. Scanner in = new Scanner(System. digits). temp = temp/10.println(n + " is not an Armstrong number. } if (n == sum) System.println("Input a number to check if it is an Armstrong number"). } static int power(int n. } } } 27.Technolamror status = 1. temp = n. for (c = 1. p = 1. digits = 0.com Need More PDF Summit Here . sum = sum + power(remainder. www. Check no is Armstrong or not in java Program import java. c++) p = p*n. } temp = n. else System. int r) { int c.Scanner. temp. sum = 0.in).println(n + " is an Armstrong number."). return p.nextInt(). num++. // Count number of digits while (temp != 0) { digits++. temp = temp/10.out. remainder.util. class ArmstrongNumber { public static void main(String args[]) { int n.out.TechnoLamror. while (temp != 0) { remainder = temp%10. System. n = in. Scanner.print(num+" "). System. class SubstringsOfAString { public static void main(String args[]) { String string.out. System. } } } 29. } System.length().println(). c. length = string. string = in. sub. num++.out. Scanner in = new Scanner(System. Scanner in = new Scanner(System. Print Floyd’s Triangle in java Program import java. int i.Technolamror } } 28. Find All substring of string in java Program import java. length. for ( c = 1 .out. class FloydTriangle { public static void main(String args[]) { int n. www.out. System. num = 1.nextInt(). n = in.Scanner.TechnoLamror.nextLine(). d++ ) { System. d <= c .util. c <= n .println("Enter the number of rows of floyd's triangle you want").in). c.println("Enter a string to print it's all substrings"). d.com Need More PDF Summit Here .in). c++ ) { for ( d = 1 .println("Floyd's triangle :-").out.util. Scanner in = new Scanner(System.out.println("Reverse of entered string is: "+reverse).println(a. i >= 0 .*. c < length . c++ ) { for( i = 1 . System. i-.println(sub). i++ ) { sub = string.out. } } //Using Internal java Methog class InvertString { public static void main(String args[]) { StringBuffer a = new StringBuffer("Java programming is fun").Technolamror System. reverse = "".nextLine(). original = in.length().out.) reverse = reverse + original.com Need More PDF Summit Here .substring(c. for( c = 0 .println("Enter a string to reverse"). } } www. System.TechnoLamror. int length = original. } } } } 30.out.in).charAt(i).println("Substrings of \""+string+"\" are :-"). class ReverseString { public static void main(String args[]) { String original. System.reverse()).out. i <= length . for ( int i = length . c+i). Print reverse string in java Program import java.c . System.util.1 . util. for ( int i = length . Scanner in = new Scanner(System.length().out.in). end.util. } } //Another Method import java. begin.equals(reverse)) System. inputString = in.TechnoLamror.) reverse = reverse + original. Check Given No is palindrome or Not in java Program import java.out. middle = (begin + end)/2. i <= middle.out. } else { break.println("Entered string is a palindrome."). } } www. for (i = begin.com Need More PDF Summit Here .charAt(i). Scanner in = new Scanner(System.nextLine().charAt(end)) { begin++.charAt(begin) == inputString.length(). int length = original.nextLine().in).1. reverse = "".println("Entered string is not a palindrome. int length = inputString.*.println("Enter a string to check if it is a palindrome"). middle.println("Input a string"). System.*.Technolamror 31. else System. i-. original = in. i++) { if (inputString. end--. int i. i >= 0. class Palindrome { public static void main(String args[]) { String original. class Palindrome { public static void main(String args[]) { String inputString. begin = 0.").1. System. if (original.out. end = length . int sum[][] = new int[m][n]. How to add two matrix in java Program import java. for ( c = 0 .Scanner.println(). d < n . d < n . n. int first[][] = new int[m][n].println("Enter the elements of second matrix").util. } } } 32. c++ ) for ( d = 0 .print(sum[c][d]+"\t"). d < n .nextInt().nextInt().out. c++ ) for ( d = 0 . c < m .out. c < m .out. c++ ) for ( d = 0 .TechnoLamror. d. d++ ) System.println("Palindrome"). System. www. System. c++ ) { for ( d = 0 . for ( c = 0 .out. System.nextInt().nextInt().out.out. c < m .in). int second[][] = new int[m][n].println("Not a palindrome"). m = in. c < m . n = in. d++ ) sum[c][d] = first[c][d] + second[c][d].println("Sum of entered matrices:-").out.println("Enter the elements of first matrix").out. Scanner in = new Scanner(System. to subtract matrices //replace '+' with '-' System. c. class AddTwoMatrix { public static void main(String args[]) { int m. d < n .com Need More PDF Summit Here . for ( c = 0 . } else { System.println("Enter the number of rows and columns of matrix"). d++ ) first[c][d] = in. d++ ) second[c][d] = in. for ( c = 0 . System.Technolamror if (i == middle + 1) { System. if ( n != p ) System. for ( c = 0 . c < m .nextInt(). d < q .out. c++ ) { for ( d = 0 . k.out.nextInt(). c.nextInt(). Scanner in = new Scanner(System.out.Technolamror } } } 33. c < p .in).out. m = in. for ( c = 0 . class MatrixMultiplication { public static void main(String args[]) { int m.nextInt(). c++ ) for ( d = 0 . System. System.Scanner.println("Enter the elements of second matrix"). q = in. d++ ) second[c][d] = in. d < n . How to multiply two matrix in java Program import java. System. d++ ) first[c][d] = in. k < p . sum = 0. d. n = in. c++ ) for ( d = 0 .println("Enter the elements of first matrix").out. System.println("Enter the number of rows and columns of first matrix"). q.TechnoLamror.nextInt(). int multiply[][] = new int[m][q].nextInt(). p. p = in. c < m . n.println("Matrices with entered orders can't be multiplied with each other. int first[][] = new int[m][n].").println("Enter the number of rows and columns of second matrix"). else { int second[][] = new int[p][q]. for ( c = 0 . d++ ) { for ( k = 0 .util. k++ ) { www.com Need More PDF Summit Here . d < q . d < n .println("Product of entered matrices:-"). c < m .out.in). c. sum = 0.print(multiply[c][d]+"\t"). n. } } System.print("\n").nextInt(). for ( c = 0 . m = in. c++ ) { for ( d = 0 . c++ ) for ( d = 0 .Scanner.util.Technolamror sum = sum + first[c][k]*second[k][d]. d < n . c < m .TechnoLamror. d++ ) transpose[d][c] = matrix[c][d].println("Enter the elements of matrix"). int transpose[][] = new int[n][m]. c++ ) { for ( d = 0 . for ( c = 0 . d++ ) matrix[c][d] = in. System. n = in. c < m .nextInt().nextInt(). } } } } 34. d. } multiply[c][d] = sum. System.out. System. Scanner in = new Scanner(System. How to get transpose of matrix in java Program import java.println("Enter the number of rows and columns of matrix").out.out.com Need More PDF Summit Here . class TransposeAMatrix { public static void main(String args[]) { int m. for ( c = 0 . } www. int matrix[][] = new int[m][n].out. d++ ) System. d < q . println(index1+" "+index2).out.println("Transpose of entered matrix:-"). //true System. c++ ) { for ( d = 0 . d < m .TechnoLamror.out.out. How to compare 2 string in java Program public class LastIndexOfExample{ public static void main(String args[]){ String s1="hello". d++ ) System.out.Technolamror System.println(s1.com Need More PDF Summit Here .//returns the index of is substring int index2=s1.indexOf("is").//false } } 37. }} 36.indexOf("index").println(s1.endsWith("r")). How to use indesOf() in java Program public class IndexOfExample{ public static void main(String args[]){ String s1="this is index of example".println(s1.//returns the index of index substring System.println(s1.out. //true System. String s4="hemlo". c < n .out. System. System. System.out. } } } 35.print("\n"). for ( c = 0 .compareTo(s4)).println(s1. String s2="hello". How to string width with specific char in java Program class StringEndwith{ public static void main(String args[]){ String s1="java by TechnoLamror".endsWith("Lamror")).endsWith("lamror")).print(transpose[c][d]+"\t"). System. String s3="meklo". System.compareTo(s3)).out.compareTo(s2)).println(s1.out.//2 8 www.out. //passing substring int index1=s1. } }} 40.out.". String[] words=s1.4). How to replace string with another string in java Program public class ReplaceAllExample2{ public static void main(String args[]){ String s1="My name is Rajendra.out.//returns the index of is substring after 4th index System.out. My name is lamror.Technolamror //passing substring with from index int index3=s1.e.println(s1.toLowerCase().println(index4)."was").split("\\s").trim()+"Technolamror"). How to remove space in string both end in java Program public class StringTrimExample{ public static void main(String args[]){ String s1=" hello string ".println(s1+"Technolamror").indexOf("is".//returns the index of s char value System. How to convert all char in string lower case in java Program public public String String class StringLowerExample{ static void main(String args[]){ s1="TECHNOLAMROR by Rajendralamror HELLO stRIng".//splits the string based on whitespace //using java foreach loop to print elements of string array for(String w:words){ System.out.//without trim() System.com Need More PDF Summit Here .//3 }} 38.println(index3). the index of another is //passing char value int index4=s1.TechnoLamror. }} 39. My name is Technolamror. www.out. How to split string in java Program public class SplitExample{ public static void main(String args[]){ String s1="java string split method by Technolamror". String replaceString=s1.//replaces all occurrences of "is" to "was" System. System. s1lower=s1.//with trim() }} 41.out.indexOf('s').replaceAll("is".println(replaceString).//5 i.println(w). out.println(s1lower).println("Static method can be called without creating object").TechnoLamror. // Find length of string www.println("Constructor method is called when an object of it's class is created").out.nonStaticMethod(). How to create method in java Program class Methods { // Constructor method Methods() { System. } // Non static method void nonStaticMethod() { System. System. Concatenate and Replace String in Java Program class StringMethods { public static void main(String args[]) { int n. }} 42. Find Length.println("Non static method must be called by creating an object"). } // Main method where program execution begins public static void main(String[] args) { staticMethod(). u = "".out. object.Technolamror System. String s = "Java programming". } // Static method static void staticMethod() { System.out. t = "". } } 43. Methods object = new Methods().out.com Need More PDF Summit Here .println(s). ").out. // Replace characters in string t = s. } } } 45.exit(1).out. We need to open Program in speciif window class StaticBlock { public static void main(String[] args) { System.out.out. How Static block working in java Program class StaticBlock { public static void main(String[] args) { System. System.").println("Static block is executed before main method. //calling without object www.length().println(t).out. } static { String os = System. "C++").println("You are using Windows_NT operating system. // Concatenating string with another string u = s.println(s). System.out.concat(" is fun"). } } //Static Block Application …. } } 44.Technolamror n = s.TechnoLamror. if (os.println("Main method is executed.println(u). Difference between Static and Instance method working in java Program class Difference { public static void main(String[] args) { display().equals("Windows_NT") != true) { System. System. System. System.replace("Java". } static { System.").out.println("Number of characters = " + n).out.com Need More PDF Summit Here .getenv("OS").println(s). println("Power gone! Shut down your PC soon.com Need More PDF Summit Here .out. How to create Multiple class in java Program class Computer { Computer() { System.").")."). } void show(){ System.computer_method(). your.laptop_method().out.out. } } class Laptop { Laptop() { System.").out. } www.println("99% Battery available.println("Constructor method called. } public static void main(String[] args) { Computer my = new Computer()."). } void computer_method() { System.println("Java is awesome..println("Constructor of Computer class. //calling using object } static void display() { System. } void laptop_method() { System.out. How to create constructor in java Program class Programming { //constructor method Programming() { System. } } 47.out.println("Programming is amazing.Technolamror Difference t = new Difference(). } } 46. t..TechnoLamror. Laptop your = new Laptop().show().").println("Constructor of Laptop class. my.").out. setName("C++").println("Language name: " + name).in)."). } void getName() { System. } } 49. cpp.TechnoLamror.com Need More PDF Summit Here . www. Exception Handling java Program class Division { public static void main(String[] args) { int a.out. System.out. } Language(String t) { name = t.println("Input two integers"). b. cpp.out.getName(). How to create constructor overloading in java Program class Language { String name.getName().println("Constructor method called. Language java = new Language("Java"). Scanner input = new Scanner(System.Technolamror public static void main(String[] args) { Programming object = new Programming(). //creating object } } 48. result. java. Language() { System. } public static void main(String[] args) { Language cpp = new Language(). } void setName(String t) { name = t. // try block try { result = a / b. Advantage of Finally in Exception Handling java Program class Allocate { public static void main(String[] args) { try { long data[] = new long[1000000000].out. System.").println("Exception caught: Division by zero. } // catch block catch (ArithmeticException e) { System.out.nextInt().com Need More PDF Summit Here .out.Technolamror a = input.println("Result = " + result). } finally { System. } } 51.out. else System.out.nextInt().TechnoLamror..println("finally block will execute always. } public static void main(String args[]){ validate(13).. b = input. } catch (Exception e) { System.println(e). } } } 50. } } } www. How to throw exception in java Program public class TestThrow1{ static void validate(int age){ if(age<18) throw new ArithmeticException("not valid"). System.println("rest of the code.println("welcome to vote on Technolamror").").").out. out.sql.TechnoLamror.display(). } } 53. hour.get(Calendar.get(Calendar.sql.currentTimeMillis(). month.get(Calendar. hour = date. second = date. System.Date date=new java.out.get(Calendar.get(Calendar.YEAR). minute = date.println(date). How to print date and time in java Program public class SQLDateExample { public static void main(String[] args) { long millis=System. www.DAY_OF_MONTH). } // Defining method declared in interface public void display() { System.Date(millis). obj.get(Calendar. year. public void display(). int second. month = date. minute.com Need More PDF Summit Here .*.HOUR).SECOND).MONTH). java.Technolamror 52. GregorianCalendar date = new GregorianCalendar(). year = date. } class Simple implements Info { public static void main(String []args) { Simple obj = new Simple(). class GetCurrentDateAndTime { public static void main(String args[]) { int day. day = date. How to create Interface in java Program interface Info { static final String language = "Java".println(language + " is awesome").util.MINUTE). } } /// Another Way import java. format(date).out.println(date). System. SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy").println("Date Format with dd MMMM yyyy zzzz : "+strDate). strDate = formatter. formatter = new SimpleDateFormat("E. dd MMM yyyy HH:mm:ss z"). } } 55. } } 54.sql. formatter = new SimpleDateFormat("dd-M-yyyy hh:mm:ss"). formatter = new SimpleDateFormat("dd MMMM yyyy zzzz").Date.text. import java.out. "+hour+" : "+minute+" : "+second). String strDate = formatter.out.println("Date Format with dd MMMM yyyy : "+strDate).println("Date formate chnage by Technolamror "). } } www.//converting string into sql date System.println("Current time is "+day+"/"+(month+1)+"/"+year). How to Date format in java Program import java. How to SQL Date in java Program import java.format(date). System.util.Locale.println("Date Format with dd-M-yyyy hh:mm:ss : "+strDate).out.println("Date Format with MM/dd/yyyy : "+strDate). System. strDate = formatter.format(date).Date.out.out.println("Date Format with E. System.text.println("Current date is System.util.out. import java. System. Date date=Date. formatter = new SimpleDateFormat("dd MMMM yyyy").out.format(date).format(date).valueOf(str). strDate = formatter. dd MMM yyyy HH:mm:ss z : "+strDate). strDate = formatter. public class SimpleDateFormatExample2 { public static void main(String[] args) { Date date = new Date(). import java.com Need More PDF Summit Here .out.SimpleDateFormat.Technolamror System.ParseException.TechnoLamror. public class StringToSQLDateExample { public static void main(String[] args) { String str="2015-03-31". System. com Need More PDF Summit Here . 100] for (c = 1.net.getRuntime().TechnoLamror.out.getLocalHost()). class RandomNumbers { public static void main(String[] args) { int c. System.gc().println("Free memory in JVM after Garbage Collection = "+rs.out.out. } } } 57.Technolamror 56. How to get own IP Address in java Program import java. } } 58.InetAddress.println(InetAddress. class IPAddress { public static void main(String args[]) throws Exception { System. rs. c <= 10. // random integers in [0. } } www.out. class GarbageCollection { public static void main(String s[]) throws Exception { Runtime rs = Runtime. How to Generate random number in java Program import java.println(t.freeMemory()). System.*. How perform garbage collection in java Program import java. Random t = new Random().util.println("Free memory in JVM before Garbage Collection = "+rs.util.*.freeMemory()).nextInt(100)). c++) { System. Leaner search Program in java import java. n.util.println("Enter value to find").out.exec("notepad").println(search + " is present at location " + (c + 1) + ".TechnoLamror.Technolamror 59. Scanner in = new Scanner(System.out.*.out. search = in.in). n = in.out.Scanner.println(e). c++) array[c] = in.nextInt(). import java. for (c = 0. How to open notepad in java Program import java.nextInt(). search.io. class Notepad { public static void main(String[] args) { Runtime rs = Runtime.println("Enter " + n + " integers"). c < n.out. for (c = 0.getRuntime(). array[].com Need More PDF Summit Here . c < n. array = new int[n].println("Enter number of elements"). System. } www.util."). break.nextInt(). } } } 60. try { rs. System.*. } catch (IOException e) { System. c++) { if (array[c] == search) /* Searching element is present */ { System. class LinearSearch { public static void main(String args[]) { int c. System. println("Enter value to find").nextInt().1.println("Enter " + n + " integers"). } if ( first > last ) System.TechnoLamror.out. first. array = new int[n].println(search + " found at location " + (middle + 1) + ". } } 61.out. search. class BinarySearch { public static void main(String args[]) { int c. last = n ."). System.in).com Need More PDF Summit Here . while( first <= last ) { if ( array[middle] < search ) first = middle + 1.println("Enter number of elements"). middle. search = in. first = 0.util.out. n.nextInt(). Binary search Program in java import java. c < n. else if ( array[middle] == search ) { System.1.out. System. middle = (first + last)/2.\n").println(search + " is not present in the list. last. Scanner in = new Scanner(System.out.nextInt(). System. } } www. for (c = 0. middle = (first + last)/2.Scanner. n = in. } else last = middle .Technolamror } if (c == n) /* Searching element is absent */ System. break."). array[].out.println(search + " is not present in array. c++) array[c] = in. How to connect Database using java Program import java.println("Sorted list of numbers"). System.forName("oracle. c++) array[c] = in.1. } } } System. array[d+1] = swap. class OracleCon{ public static void main(String args[]){ try{ //step1 load the driver class Class. c < n. for (c = 0.println("Input number of integers to sort").OracleDriver").println("Enter " + n + " integers").out. c++) { for (d = 0.out. } } 63.Scanner.*. //step2 create the connection object www.sql. c < ( n . array[d] = array[d+1]. n = in.c . d++) { if (array[d] > array[d+1]) /* For descending order use < */ { swap = array[d].Technolamror 62. d < n . c++) System.TechnoLamror.in).driver. swap.out.println(array[c]). System.nextInt(). c < n.nextInt(). int array[] = new int[n]. for (c = 0. Bubble sort Program in java import java.jdbc.out. c. Scanner in = new Scanner(System.1 ). class BubbleSort { public static void main(String []args) { int n. d.util.com Need More PDF Summit Here . for (c = 0. prepareStatement("insert into Emp values(?.close().OracleDriver")."system". PreparedStatement stmt=con.sql.*.setString(2.close(). con.out. Connection con=DriverManager. Connection con=DriverManager.forName("oracle.executeUpdate().Technolamror Connection con=DriverManager. stmt. PreparedStatement ps=con. }catch(Exception e){ System.println(e).*.//1 specifies the first parameter in the query stmt.setInt(1. www.println(rs."oracl e").out.?)")."Ratan").} } } 64. while(rs.OracleDriver").prepareStatement("insert into imgtable values(?."system".getConnection("jdbc:oracle:thin:@localhost:1521:xe".} } } 65.*.createStatement().executeQuery("select * from emp"). How to insert image using JDBC in java Program import java.io. import java. int i=stmt.getConnection("jdbc:oracle:thin:@localhost:1521:xe".getString(2)+" "+rs.println(i+" records inserted").jdbc.com Need More PDF Summit Here ."oracle"). How to insert data in table using JDBC in java Program import java.getConnection( "jdbc:oracle:thin:@localhost:1521:xe". //step5 close the connection object con.next()) System. //step3 create the statement object Statement stmt=con.out.out.println(e).getInt(1)+" "+rs. class InsertPrepared{ public static void main(String args[]){ try{ Class. }catch(Exception e){ System.TechnoLamror. public class InsertImage { public static void main(String[] args) { try{ Class. //step4 execute query ResultSet rs=stmt.jdbc.sql.?)").101).driver. System.getString(3)).driver."system"."oracl e").forName("oracle. TechnoLamror.close().out.out.matches(".fin.driver. CallableStatement stmt=con..jdbc."). Connection con=DriverManager. } } 67.1011).jpg").compile("."system".execute(). stmt.setBinaryStream(2.getConnection("jdbc:oracle:thin:@localhost:1521:xe".out.println("thread is running.s".available()).executeUpdate().util. public class RegexExample1{ public static void main(String args[]){ //1st way Pattern p = Pattern.compile(". How to create Multithreading program in java class Multi extends Thread{ public void run(){ System. System. stmt. System.fin.setInt(1.matcher("as"). public class Proc { public static void main(String[] args) throws Exception{ Class.setString(2.println("success"). represents single character Matcher m = p. stmt.forName("oracle.*.com Need More PDF Summit Here .regex. boolean b = m."oracl e").println(i+" records affected"). //2nd way boolean b2=Pattern.setString(1.out.matches().*.Technolamror ps.println(b+" "+b2+" "+b3). //3rd way boolean b3 = Pattern.s"). ps.} } } 66. int i=ps.?)}").prepareCall("{call insertR(?. con.printStackTrace(). System.matcher("as").matches(). How to execute Procedure in JDBC in java Program import java.OracleDriver")."Technolamror")."Amit"). How to check Regular expression in java Program import java.s"). "as"). }catch (Exception e) {e. FileInputStream fin=new FileInputStream("d:\\g.. }} 68. } www.//.sql. fout.} t2.com Need More PDF Summit Here .println(e).} System.start().FileOutputStream.io.out.start(). }catch(Exception e){System. } } 69.println(i).join().i++){ try{ Thread.println("success. fout.close(). How to join thread in java program class TestJoinMethod1 extends Thread{ public void run(){ for(int i=1. System.} } } 71. } } 70.sleep(500).Technolamror public static void main(String args[]){ Multi t1=new Multi().FileInputStream.out. How to read data from text file using java program import java.start(). by Technolamror. TestJoinMethod1 t2=new TestJoinMethod1().println(e).write(65). } } public static void main(String args[]){ TestJoinMethod1 t1=new TestJoinMethod1().i<=5.out.io.. try{ t1."). }catch(Exception e){System. }catch(Exception e){System.out. t3. How to write data in text file using java program import java. t1.TechnoLamror. t1. public class DataStreamExample { www. TestJoinMethod1 t3=new TestJoinMethod1().start(). public class FileOutputStreamExample { public static void main(String args[]){ try{ FileOutputStream fout=new FileOutputStream("D:\\testout.println(e).out.txt"). io. How to create AWT program in java import java.} } } 72.getHostName()). How to get URL of site using java Programs import java. import java.setBounds(30.com Need More PDF Summit Here .out.getFile()).println("Host Name: "+url.*.} } } 73.println(e).getHost()). System. import java.com"). int i=fin.print((char)i).30). System.println("Protocol: "+url.println(e). b.getProtocol()).out.out. System. System.net.com/java").close(). fin.out.out.println("Host Name: "+ip.*.getHostAddress()).Technolamror public static void main(String args[]){ try{ FileInputStream fin=new FileInputStream("D:\\Technolamror.println("IP Address: "+ip.*. }catch(Exception e){System.80.net.getPort()).technolamror.io.out.out.*. class First extends Frame{ First(){ Button b=new Button("click me").println("File Name: "+url.out. public class InetDemo{ public static void main(String[] args){ try{ InetAddress ip=InetAddress.txt").out.read().println(e).Technolamror.getByName("www.100.awt.// setting button position www. How to get IP address from site URL using java program import java. }catch(Exception e){System. System. System. public class URLDemo{ public static void main(String[] args){ try{ URL url=new URL("http://www.TechnoLamror. System.println("Port Number: "+url.*.} } } 74.out. }catch(Exception e){System. f.setLayout(null).400).awt.100."). public class ChoiceExample { ChoiceExample(){ www. l2. class LabelExample{ public static void main(String args[]){ Frame f= new Frame("Label Example by Technolamror"). f.//frame size 300 width and 300 height setLayout(null).").*.awt.add(l2).l2.add(l1).300).30). f.setSize(400. f. f. f.setLayout(null). How to dropdown in AWT program in java import java. TextArea area=new TextArea("Welcome to Technolamror"). } } 77. Label l1.30).TechnoLamror.//adding button into frame setSize(300.*. 100. 100. l1=new Label("First Label. 300. f.setBounds(50.add(area).awt.setBounds(50. } public static void main(String args[]) { new TextAreaExample().//now frame will be visible.setVisible(true). How to add lable in AWT program in java import java.150. l2=new Label("Second Label.30.com Need More PDF Summit Here .300). l1. f. How to add text area program in java import java.setVisible(true).400).setBounds(10.*. area. }} 75. public class TextAreaExample { TextAreaExample(){ Frame f= new Frame().Technolamror add(b). } } 76.setSize(400.//no layout manager setVisible(true). f. by default not visible } public static void main(String args[]){ First f=new First(). com Need More PDF Summit Here .50). 40). } public static void main(String args[]) www.setBounds(100. } } 78.*.50). width.100. height f.setLayout(null). public class CheckBoxExample { CheckBoxExample(){ JFrame f= new JFrame("CheckBox Example by Technolamror").add(c). f. 50.100.//creating instance of JButton b.TechnoLamror.100.add("Item 4").//x axis. c.//using no layout managers f.add(b). true).500). checkBox1.add(checkBox1). checkBox2.//creating instance of JFrame JButton b=new JButton("click").//adding button in JFrame f.setBounds(100.*.setBounds(100.setBounds(130. f. f.//making the frame visible } } 79. How to create Swing program in java import javax. f. y axis. public class FirstSwingExample { public static void main(String[] args) { JFrame f=new JFrame(). c.swing.add("Item 3 by Technolamror"). f. JCheckBox checkBox1 = new JCheckBox("C++"). c.setVisible(true).400). f. c.100.75). JCheckBox checkBox2 = new JCheckBox("Java".//400 width and 500 height f. } public static void main(String args[]) { new ChoiceExample().swing.add(checkBox2).setLayout(null). c. f. 75.add("Item 5").150.setVisible(true).add("Item 2 by Lamror").400).setLayout(null).setSize(400. f.setSize(400. How to add checkbox in Swing program in java import javax.setSize(400. c.add("Item 1 by Rajendra"). 50. Choice c=new Choice(). f.setVisible(true).Technolamror Frame f= new Frame(). parseFloat("23.out. System.println(s+100). }} 80. System.TechnoLamror.println(i+100).println(s+100).com Need More PDF Summit Here .//200100 because + is string concatenation operator System. long l=Long. }} 83. }} 84. int i=Integer.6").//300 because + is binary plus operator }} 81.parseLong(s).valueOf(i). How to convert integer to string in java program public class IntToStringExample1{ public static void main(String args[]){ int i=200.//300 because + is binary plus operator System. float f=Float.println(i+100).println(l). System.6".out.out. How to convert string to integer in java program public class StringToIntExample{ public static void main(String args[]){ String s="200".//200100 because + is string concatenation operator }} 82. String s=String.out.out. How to convert string to double in java program public class StringToDoubleExample{ public static void main(String args[]){ www.Technolamror { new CheckBoxExample().println(f).out. System. How to convert string to float in java public class StringToFloatExample{ public static void main(String args[]){ String s="23.parseInt(s). How to convert string to long in java public class StringToLongExample{ public static void main(String args[]){ String s="9990449935". SimpleDateFormat formatter3=new SimpleDateFormat("MM dd.out. list. SimpleDateFormat formatter6=new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss").//Creating arraylist list. String sDate6 = "31-Dec-1998 23:37:50".util. SimpleDateFormat formatter5=new SimpleDateFormat("E.parse(sDate3).println(sDate6+"\t"+date6).parse(sDate1). }} 85.out. String sDate3 = "12 31. Date date1=formatter1.println(sDate2+"\t"+date2).parseDouble("23. MMM dd yyyy HH:mm:ss"). MMM dd yyyy").out.out. double d=Double. System.println(sDate3+"\t"+date3). System. Date date6=formatter6.add("Rajendra"). Date date4=formatter4. class Arrylist_Technolamror{ public static void main(String args[]){ ArrayList<String> list=new ArrayList<String>().//Adding object in arraylist list.6". String sDate5 = "Thu. Date date2=formatter2. String sDate4 = "Thu.SimpleDateFormat. System.TechnoLamror.out. String sDate2 = "31-Dec-1998". System. System.com Need More PDF Summit Here .text.util. } } 86. SimpleDateFormat formatter2=new SimpleDateFormat("dd-MMM-yyyy").println(sDate4+"\t"+date4). How to convert string to date in java program import java. Dec 31 1998".parse(sDate4). Date date3=formatter3.parse(sDate5).out.add("Mahendra").parse(sDate2).6"). public class StringToDateExample1 { public static void main(String[] args)throws Exception { String sDate1="31/12/1998".Technolamror String s="23.parse(sDate6). System. System.println(d). 1998".out. Create ArrayList program in java import java.*. Date date5=formatter5.out. www. SimpleDateFormat formatter1=new SimpleDateFormat("dd/MM/yyyy").add("Raja").println(sDate1+"\t"+date1). SimpleDateFormat formatter4=new SimpleDateFormat("E. System. Dec 31 1998 23:37:50". list. yyyy").println("String to Date converter by technolamror"). import java.println(sDate5+"\t"+date5).add("Technolamror").Date. while(itr.name = name.iterator(). Book b3=new Book(103. } } } 88.quantity = quantity.id = id.add("Rajendra").publisher = publisher. int quantity.util. String publisher. this.next()).publisher.*.hasNext()){ System."Yashwant Kanetkar". String name.util. this. //Creating Books Book b1=new Book(101. How to create LinkedList program in java import java. class Book { int id.TechnoLamror.next()). this. public class LinkedList_technolamror{ public static void main(String args[]){ Linkedal<String> al=new Linkedal<String>(). String author. Book b2=new Book(102. How to ArrayList using list interface program in java import java.4). Iterator<String> itr=al. public Book(int id. } } } 87.out.author.out.iterator().add("Raja").add("Mahendra")."Galvin"."Java Program Questation"."BPB". al. } } public class ListIteratorExample { public static void main(String[] args) { //Creating list of Books List<Book> list=new ArrayList<Book>(). //Adding Books to list www. String name. while(itr.*. this."Technolamror"."Operating System"."Rajendra".author = author.com Need More PDF Summit Here .//Adding object in LinkedList al.add("Technolamror")."Let us C".println(itr."Wiley". al.6).hasNext()){ System. al.8).Technolamror //Traversing list through Iterator Iterator itr=list.println(itr. int quantity) { this. out.*.hasNext()){ Book st=(Book)itr. class TestCollection9{ public static void main(String args[]){ //Creating HashSet and adding elements HashSet<String> set=new HashSet<String>().*.id+" "+b. How to create Hashset program in java import java.add("Technolamror").Technolamror list.util. How to create LinkedHashSet program in java import java. System. set.println("Original content of list is: ").println(itr.add(b3).quantity+" "+st. while(itr.out. list.out.com Need More PDF Summit Here . while(itr.add("Rajendra"). set.println(st. al. class LinkedHashSet_Technolamror{ public static void main(String args[]){ LinkedHashSet<String> al=new LinkedHashSet<String>().name+" "+st.hasNext()){ System.add(b2).add(b1).add("Ravi").author+" "+b.println(itr.util.next()). while(itr.author+" "+st.TechnoLamror.println(b. //Traversing list for(Book b:list){ System. al.next(). } } } 90. al. } ListIterator<Book> itr=list. set.println("Modified content of list in backward is: ").add("Raja").id).add("Raja").out.add("Technolamror"). System. list.add("Rajendra"). System. Iterator<String> itr=al. al.publisher+" "+b. www. } } } 89.add("Ravi").iterator().hasNext()){ System.listIterator().next()). set.publisher+" "+st.quantity).out. //Traversing elements Iterator<String> itr=set.name+" "+b.out.iterator(). System. queue.add("Raja"). while(itr.out.println(itr2.out.hasNext()){ System. al. System. class PriorityQueue_Technolamror{ public static void main(String args[]){ PriorityQueue<String> queue=new PriorityQueue<String>(). How to create PriorityQueue program in java import java. while(itr2.add("Rahul").next()).iterator(). al. class TreeSet_Technolamror{ public static void main(String args[]){ //Creating and adding elements TreeSet<String> al=new TreeSet<String>().iterator().out. System. } } } 92.hasNext()){ System.println("head:"+queue. } } } www.println(itr. queue.remove().element()).out.add("Technolamror"). } queue.util.out.next()). queue.iterator().println("head:"+queue.add("Raja"). Iterator<String> itr2=queue.peek()).out.poll().hasNext()){ System.add("Mahendra").util. queue.Technolamror } } } 91.println("after removing two elements:"). while(itr. queue.println(itr.next()). queue. ments Iterator<String> itr=al. al.*.add("Rajendra").out.add("Ravi"). How to create TreeSet program in java import java.add("Technolamror").println("iterating the queue elements:").com Need More PDF Summit Here . System. Iterator itr=queue. al.add("Rajendra").*.TechnoLamror. Entry m:hm.println(m.getKey()+" "+m.String> hm=new TreeMap<Integer."Lamror"). class LinkedHashMap_Technolmaror{ public static void main(String args[]){ LinkedHashMap<Integer.println(m.getKey()+" "+m."Rajendra")."Amit").put(101.TechnoLamror. map. } } } 94."Vijay"). for(Map.String> hm=new LinkedHashMap<Integer. How to create HashMap using map interface program in java import java. } } } www. class MapInterfaceExample{ public static void main(String args[]){ Map<Integer.Entry m:map.put(101. class TreeMap_Technolamror{ public static void main(String args[]){ TreeMap<Integer.String> map=new HashMap<Integer.util."Technolamror"). hm.util. map.put(100.*.out.String>().out.println(m. for(Map."Technolamror").Technolamror 93.util.put(103.getValue()). hm."Technolamror"). for(Map.com Need More PDF Summit Here .out. How to create LinkedHashMap program in java import java. How to create TreeMap program in java import java.*. hm.getValue()).put(102.entrySet()){ System.put(102.String>(). hm. map.*.String>()."Ravi").put(100.entrySet()){ System. hm.getValue()).Entry m:hm. hm. } } } 95.put(101.put(100."Vijay").put(102.entrySet()){ System.getKey()+" "+m."Rajendra"). hm. Technolamror 96.put(101.*. a[3]=40. } www.length. How to create Hashtable program in java import java.Entry m:hm. a[2]=70.//initialization a[1]=20.i<a.println().i++)//length is the property of array System. for(Map.println(a[i]).out."Rajendra").out. hm. //printing 2D array for(int i=0.TechnoLamror.put(103.getValue()). hm.5}}. hm.{2.//declaration and instantiation a[0]=10.i<3."Bipin"). }} 98.entrySet()){ System. } System.print(arr[i][j]+" ").j<3.println(m.com Need More PDF Summit Here .put(102.String>(). a[4]=50. } } } 97.2.5}. class Hashtable_Technolamror{ public static void main(String args[]){ Hashtable<Integer. How to create Multidimensional array program in java class Multi_Array{ public static void main(String args[]){ //declaring and initializing 2D array int arr[][]={{1. //printing array for(int i=0.4.put(100.out. How to create Array program in java class Array_Technolamror{ public static void main(String args[]){ int a[]=new int[5]."Pankaj").3}.i++){ for(int j=0.getKey()+" "+m.util.4.out. hm."Praveen").String> hm=new Hashtable<Integer.{4.j++){ System. System.TechnoLamror. ICICI i=new ICICI().out. } } 100. System.} } class ICICI extends Bank{ int getRateOfInterest(){return 7.out.} } class Test2{ public static void main(String args[]){ SBI s=new SBI().println("ICICI Rate of Interest: "+i. System.println("AXIS Rate of Interest: "+a.out. How to create Method Overriding program in java class Bank{ int getRateOfInterest(){return 0.getRateOfInterest()).Technolamror }} 99. else return(n * factorial(n-1)). How to create Find Factorial No using Recursion Program in java public class Recursion_Technolamror { static int factorial(int n){ if (n == 1) return 1.} } class AXIS extends Bank{ int getRateOfInterest(){return 9. AXIS a=new AXIS().getRateOfInterest()).println("SBI Rate of Interest: "+s. } public static void main(String[] args) { System.out.println("Factorial of 5 is: "+factorial(5)).} } class SBI extends Bank{ int getRateOfInterest(){return 8. } } www.com Need More PDF Summit Here .getRateOfInterest()). TechnoLamror.Technolamror Thank You For Reading Give Your FeedBack If You Required Other PDF Submit Your Request Here Rajendra lamror www.com Need More PDF Summit Here .