5:09 pm - Monday April 24, 2017

Program for creating stringtokenizer using Object nextElement()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

BACK

Program for creating stringtokenizer using Object nextElement()

Example Program


import java.util.StringTokenizer;

public class StringTokenizernextele {

	public static void main(String[] args) {

		// creating stringtokenizer

		StringTokenizer st = new StringTokenizer(
				"Java is a platform independent language");

		// move to next element

		st.nextElement();

		// check to next to next element

		System.out.println("Next element is : " + st.nextElement());

	}

}

 

Output

Next element is : is

Explanation

public Object nextElement()

Returns the same value as the nextToken method, except that its declared return value is Object rather than String. It exists so that this class can implement the Enumeration interface.

Specified by:

nextElement in interface Enumeration<Object>

Returns:

the next token in the string.

Throws:

NoSuchElementException – if there are no more tokens in this tokenizer’s string.

See Also:

Enumeration, nextToken()

BACK

 

Filed in: Z-A All Java Codes

Comments are closed.