83.6k views
2 votes
Consider the Java segment: String line1 = new String("c = 1 + 2 + 3") ; StringTokenizer tok = new StringTokenizer(line1, delimArg); For the String line1 to have 4 tokens, delimArg should be ________.

User Nodebase
by
4.1k points

1 Answer

6 votes

Answer:

+=

Step-by-step explanation:

StringTokenizer(line1, delimArg); delimArg is the delimiter that is used to create tokens from line1. (It enables us to break the string in pieces)

If line1 is equal to c = 1 + 2 + 3 and we want to have four tokens, pieces, then we need to use += as a delimiter to have c, 1, 2, and 3 as pieces.

For example, if we used + as a delimiter, we would have 3 pieces: c=1, 2, 3

User Soulfire
by
4.1k points