Remove all vowels in a string with Java

后端 未结 5 896
不思量自难忘°
不思量自难忘° 2021-01-19 12:46

I am doing a homework assignment for my Computer Science course. The task is to get a users input, remove all of the vowels, and then print the new statement.

I kno

5条回答
  •  礼貌的吻别
    2021-01-19 13:04

    I think what he might want is for you to read the string, create a new empty string (call it s), loop over your input and add all the characters that are not vowels to s (this requires an if statement). Then, you would simply print the contents of s.


    Edit: You might want to consider using a StringBuilder for this because repetitive string concatenation can hinder performance, but the idea is the same. But to be honest, I doubt it would make a noticeable difference for this type of thing.

提交回复
热议问题