java tutorials

Bubble Sort in String Program in Java

import java.util.Scanner; public class BubbleSortString { public static void main(String[] args) { String temp; String str[] = new String[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the string ar[" + i + "]:"); str[i] = sc.nextLine(); } for (int j = 0; j < str.length; j++) […]

Palindrome String

import java.util.Scanner; public class PalindromeString { public static void main(String[] args) { String st,revSt=””; int l; Scanner sc=new Scanner(System.in); System.out.print(“Enter String:”); st=sc.nextLine(); l=st.length(); for (int i = l-1; i >= 0; i–) { char ch; ch=st.charAt(i); revSt=revSt+ch; } if(st.equals(revSt)) { System.out.println(“Palindrome String”); } else { System.out.println(“Not Palindrome String”); } } } Output: Enter String:asdsa Palindrome […]

Piglatin Form Program in Java

Piglatin Form First, the vowels are checked and first occurring vowel in the word is found. Then, the Piglatin word is formed by taking the substring from first vowel position and then concatinating it with the letters from first letter till the first vowel i.e. before the first vowel.Finally a string “AY” is added at […]

Find Vowels And Capital Letter in Array Program in Java

import java.util.Scanner; public class FindVowelAndCapitalInArray { public static void main(String[] args) { int vowelCount=0, upperCaseCount = 0; char ar[] = new char[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the number ar[" + i + "]:"); ar[i] = sc.next().charAt(0); } System.out.println("-------------------------------"); for (int i = 0; […]

Find Positive and Negative Numbers in Array Program in Java

import java.util.Scanner; public class FindPositiveAndNegative { public static void main(String[] args) { int ar[] = new int[10]; Scanner sc = new Scanner(System.in); for (int i = 0; i < 10; i++) { System.out.print("Enter the number ar[" + i + "]:"); ar[i] = sc.nextInt(); } System.out.println("The +ve numbers are:"); for (int i = 0; i < […]

Binary to Decimal Number Program in Java

import java.util.Scanner; /** * * @author AFAQ */ public class BinaryToDecimal { public static void main(String[] args) { int binary; Scanner sc = new Scanner(System.in); System.out.print(“Enter binary number=”); binary = sc.nextInt(); int decimal = 0; int n = 0; while (binary>0) { int temp = binary % 10; decimal += temp * Math.pow(2, n); binary […]

Java Constructors

Java constructor is similar to the method. It calls when an object(instance) of a class is created. Allocated in the memory when a constructor is called. It is used to initialize the object of a class. When an object is created using the new keyword, constructor is called. It calls a default constructor if there […]

Java Object Oriented Programming (OOPs) Concepts

Java is an Object Oriented Programming language. There are many object oriented features in java such as Inheritance, Polymorphism, Abstraction, Encapsulation etc.

The first object-oriented programming language is Simula.
Java is known as truly object-oriented programming language because all java programs is written in class.

Short Name Format Program in Java

Short Name Format Program in Java

Words in Sentence Program in Java

Words in Sentence Program in Java, Enter a sentence or string and print its words of string in java.

1 2 3 12