1:00 pm - Wednesday February 22, 2017

Program for creating stringtokenizer using display hasmoreElements

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 display hasmoreElements

Example Program


import java.util.StringTokenizer;

public class StringTokenizerTest {

	public static void main(String[] args) {

		// creating String tokenizer

		StringTokenizer st = new StringTokenizer("Hi welcome to java program");

		// checking elements

		while (st.hasMoreElements()) {

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

		}

	}

}


 

Output

Next elements :Hi

Next elements :welcome

Next elements :to

Next elements :java

Next elements :program

Explanation

public boolean hasMoreElements()

Returns the same value as the hasMoreTokens method. It exists so that this class can implement the Enumeration interface.

Specified by:

hasMoreElements in interface Enumeration<Object>

Returns:

true if there are more tokens; false otherwise.

See Also:

Enumeration, hasMoreTokens()

BACK

Filed in: Z-A All Java Codes

Comments are closed.