Scanner vs. StringTokenizer vs. String.Split

前端 未结 10 1337
太阳男子
太阳男子 2020-11-22 10:56

I just learned about Java\'s Scanner class and now I\'m wondering how it compares/competes with the StringTokenizer and String.Split. I know that the StringTokenizer and Str

10条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 11:51

    If you have a String object you want to tokenize, favor using String's split method over a StringTokenizer. If you're parsing text data from a source outside your program, like from a file, or from the user, that's where a Scanner comes in handy.

提交回复
热议问题