3:53 pm - Tuesday March 24, 4820

Author Archives: veera

Collections example programs | Java Collections tutorials

 Java Collection tutorials: AddAll() For Insert a collection element in already excisting collection LifoQueue() For View of Deque in Last-in-first-out order binarySearch(List<? extends T>,T,Comparator<?super T> For  Search a particular...

StringBuffer example programs and Tutorial in java

  Append two String using StringBuffer append() Method. Insert the String or word in a StringBuffer at the Specified Position. Replace the String or Word in a String Buffer at the Specified Position. Reverse  the String or Word in a String...

How to Add Multiple Objects to an Arraylist

BACK  Following method is used to add All object to ArrayList from other Collection Objects. Example Program import java.util.ArrayList; public class Fun { public static void main(String[] args) { ArrayList Student=new ArrayList(); Student.add("name:"); Student.add("age:"); Student.add("email:"); System.out.println("Enter...

How To Call the Hashtable method put using Properties.setProperty(String key, String value) method

BACK This tutorial explains how to Load a property list from the input character stream using Properties.load(Reader reader) method.Properties setProperty(String key, String value) calls the Hashtable method put. import java.util.Properties; public...

The Collection Program sort the specified list

BACK   The sort(List<T>, Comparator<? super T>) method is used to sort the specified list according to the order induced by the specified comparator. Example Program import java.util.*; public class Comparator1 { static...

Java Collection Singleton Map examples

BACK   The singletonMap(K, V) method is used to get an immutable map, mapping only the specified key to the specified value. Example Program import java.util.*; public class Map1 { public static void main(String[] args) { Map<Integer,...

Java Program to retain only elements in the specified collection

BACK RetailAll program to retain only elements specified in the specified collection. Example Program import java.util.ArrayList; import java.util.LinkedList; public class RetainAll { public static void main(String[] args) { LinkedList...

PriorityQueue example program to order the elements in this queue, or null if this queue is sorted according to the natural ordering of its elements use Comparator() method.

BACK This Program is used to order the elements in this queue or null if this queue is sorted according to the natural ordering of its elements  using Comparator() method. Example Program package com.example; package com.example; import...

Java Program used to remove the specified element in the list using remove() method

BACK   Remove Index example program to remove the specified element in the list. Example Program import java.util.ArrayList; public class RemoveIndex { public static void main(String[] args) { ArrayList al = new ArrayList(); al.add(“0”); al.add(“1”); al.add(“2”); al.add(“3”); System.out.println(“Arraylist...

Java Program used to ensure the minimum capacity of arraylist

BACK   The java.util.ArrayList.ensureCapacity(int minCapacity) method increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. Example...

Java Program used to create copy of an object using clone() method.

BACK The java.lang.Object.clone() creates and returns a copy of this object Example Program import java.util.GregorianCalendar; public class Clone { public static void main(String[] args) throws CloneNotSupportedException { // create...

Java Program used to iterate the elements in the arraylist and display using iterator() method

BACK Iterator program to iterate the elements in the arraylist and display Example Program import java.util.ArrayList; import java.util.Iterator; public class Iterater { public static void main(String[] args) { ArrayList<String>...

Java Program used to to remove the specified element in the list using remove() method

BACK Remove Index program to remove the specified element in the list Example Program import java.util.ArrayList; public class RemoveIndex { public static void main(String[] args) { ArrayList al = new ArrayList(); al.add(“0”); al.add(“1”); al.add(“2”); al.add(“3”); System.out.println(“Arraylist...

Java Program used to ensure the minimum capacity of arraylist using ensureCapacity() method

BACK  EnsureCapacity program to ensure the minimum capacity of arraylist Example Program import java.util.ArrayList; public class EnsureCapacity { public static void main(String[] args) { ArrayList<String> al = new ArrayList<String>(); al.add("10"); al.add("30"); al.add("60"); al.add("70"); al.add("80"); al.add("90"); al.add("10"); al.add("20"); al.add("100"); al.ensureCapacity(8); for...

Java Program used to create copy of an object using clone() method

BACK Object Clone program to create copy of an object Example Program import java.util.GregorianCalendar; public class Clone { public static void main(String[] args) throws CloneNotSupportedException { // create a gregorian calendar,...

Java Program used to get the pathname of the file using getPath() method

BACK Get Filepath program to get the pathname of the file. Example Program package service1; import java.io.File; public class StrFilepath { public static void main(String[] args) { File f = null; String v; boolean bool...

Java Program used to get the name of parent file path using getParentFile() method.

BACK Get parent file program to get the name of parent file path. Example Program package service1; import java.io.File; public class ParentFilepath { public static void main(String[] args) { File f = null; File f1 = null; String...

Java Program used to find the parent Directory of the mentioned file using getParent() method.

BACK Get Parent program to find the parent Directory of the mentioned file. Example Program package service1; import java.io.File; public class GetParent { public static void main(String[] args) { File f = null; String v; boolean...

Java Program used to get the name of the file or directory mentioned in pathname using getName() method.

BACK String Getname program to get the name of the file or directory mentioned in pathname. Example Program package service1; import java.io.File; public class StrGetname { public static void main(String[] args) { File f = null; File...

Java Program get totalspace program to get size of a partition where abstract file exists using getTotalSpace() method

BACK Get totalspace program to get size of a partition where abstract file exists. Example Program package service1; import java.io.File; public class TotalSpace { public static void main(String[] args) { File f = null; long...