Dropdowns

A number is called Capricorn or Kaprekar number whose square is divided into two parts in any conditions and parts are added, the additions of parts is equal to the number, is called Capricorn or Kaprekar number. import java.util.Scanner; public class CapricornNumber { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print(“Enter […]

java java programs number based program

Write a program to input the names of 15 cities sort in descending order using selection sort technique. import java.util.Scanner; public class SelectionSortString { public static void main(String[] args) { String cities[] = new String[15]; Scanner sc = new Scanner(System.in); int l = cities.length; System.out.println(“Enter 15 cities name:”); for (int i = 0; i < […]

java java string sorting string array

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 java tutorials

The java string replace() method returns a string replacing all the old char or CharSequence to new char or CharSequence. Since JDK 1.5, a new replace() method is introduced, allowing you to replace a sequence of char values. Java String replace(char old, char new) method example public class ReplaceExample1{ public static void main(String args[]){ String […]

java java string

The java string length() method length of the string. It returns count of total number of characters. The length of java string is same as the unicode code units of the string. Java String length() method example public class LengthExample{ public static void main(String args[]){ String s1=”javatpoint”; String s2=”python”; System.out.println(“string length is: “+s1.length());//10 is the […]

java java string

The java string lastIndexOf() method returns last index of the given character value or substring. If it is not found, it returns -1. The index counter starts from zero. Java String lastIndexOf() method example public class LastIndexOfExample{ public static void main(String args[]){ String s1=”this is index of example”;//there are 2 ‘s’ characters in this sentence […]

java java string

The java string join() method returns a string joined with given delimiter. In string join method, delimiter is copied for each elements. In case of null element, “null” is added. The join() method is included in java string since JDK 1.8. There are two types of join() methods in java string. Java String join() method […]

java java string

The java string isEmpty() method checks if this string is empty or not. It returns true, if length of string is 0 otherwise false. In other words, true is returned if string is empty otherwise it returns false. The isEmpty() method of String class is included in java string since JDK 1.6. Java String isEmpty() […]

java java string

The java string intern() method returns the interned string. It returns the canonical representation of string. It can be used to return string from memory, if it is created by new keyword. It creates exact copy of heap string object in string constant pool. Java String intern() method example public class InternExample{ public static void […]

java java string

The java string getChars() method copies the content of this string into specified char array. There are 4 arguments passed in getChars() method. The signature of getChars() method is given below: Java String getChars() method example public class StringGetCharsExample{ public static void main(String args[]){ String str = new String(“hello efaculty how r u”); char[] ch […]

java java string
On this page