Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint
Cover Image
Cover Image
Drag to reposition
Contributed Answers

Loop through the Vector elements using a ListIterator in Java

Answered on 7th Feb, 2019, 0 Views

A ListIterator can be used to traverse the elements in the forward direction as well as the reverse direction in a Vector. The method hasNext( ) in ListIterator returns true if there are more elements in the Vector while traversing in the forward direction and false otherwise. The method next( ) returns the next element in the Vector and advances the cursor position. A program that demonstr.....

Set the size of a Vector in Java

Answered on 7th Feb, 2019, 0 Views

The java.util.Vector.setSize() method can be used to set the size of a Vector in Java. If the new size that is set is greater than the old size of the Vector, then null values are added to the positions created. If the new size that is set is lesser than the old size of the Vector, then the elements at positions more than the new size are discarded. A program that demonstrates this is given.....

Print a Vector in a comma-delimited list, in index order and surrounded by square brackets ([]) in Java

Answered on 7th Feb, 2019, 0 Views

A Vector can be printed in a comma-delimited list, in index order and surrounded by square brackets ([]) by simply using System.out.println() along with the Vector object. A program that demonstrates this is given as follows:  Live Demo , The output of the above program is as follows: , Now let us understand the above program. The Vector is created. Then Vector.add() is used to add the.....

Class with a constructor to initialize instance variables in Java

Answered on 7th Feb, 2019, 0 Views

A class contains a constructor to initialize instance variables in Java. This constructor is called when the class object is created. A program that demonstrates this is given as follows:  Live Demo , The output of the above program is as follows: , Now let us understand the above program. The Student class is created with data members rno, name. The constructor Student() initializes r.....

Swap two Strings without using third user defined variable in Java

Answered on 4th Dec, 2018, 0 Views

In order to swap two strings i.e interchange the content of two strings we will use sub string method of string class in Java.First of all get the length of both strings before making any change in any of string.Now modify one string as concatenate both strings and assign to one string. After this use sub string method of String class using begin index as length of new modified string 1 an.....

Stack in Java Programming

Answered on 4th Dec, 2018, 0 Views

Stack is a subclass of Vector that implements a standard last-in, first-out stack. Stack only defines the default constructor, which creates an empty stack. Stack includes all the methods defined by Vector, and adds several of its own. , Apart from the methods inherited from its parent class Vector, Stack defines the following methods − Sr.No. Method & Description 1 boolean em.....

Set Interface in Java Programming

Answered on 3rd Dec, 2018, 0 Views

A Set is a Collection that cannot contain duplicate elements. It models the mathematical set abstraction. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited. Set also adds a stronger contract on the behavior of the equals and hashCode operations, allowing Set instances to be compared meaningfully even if their .....

Print a 2 D Array or Matrix in Java Programming

Answered on 3rd Dec, 2018, 0 Views

In this post we will try to print an array or matrix of numbers at console in same manner as we generally write on paper. For this the logic is to access each element of array one by one and make them print separated by a space and when row get to emd in matrix then we will also change the row Live Demo , ,

Null Pointer Exception in Java Programming

Answered on 3rd Dec, 2018, 0 Views

NullPointerException is a runtime exception and it is thrown when the application try to use an object reference which has a null value. For example, using a method on a null reference. Live Demo , ,

Math class methods in Java Programming

Answered on 3rd Dec, 2018, 0 Views

The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions. Following is the declaration for java.lang.Math class − , Following are the fields for java.lang.Math class − static double E − This is the double value that is closer than any other to e, the base .....

loader
Advertisements
Contribution

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.