string - How do I Remove text before a space in java? -


string str = "hello world"; int spacepos = str.indexof(" "); if (spacepos > 0) {     string youstring = str.substring(0, spacepos - 1);     system.out.println(youstring); } 

i want "world" result. how result?

use substring(startindex) form of substring method. find index of space (' '), pass result + 1 substring method , output string starting position end. follows:

string str = "hello world"; string youstring = str.substring(str.indexof(' ') + 1); system.out.println(youstring); 

Comments

Popular posts from this blog

java - HTTP Status 500 - An exception occurred processing JSP page /second.jsp at line 15 -

php - Using str_replace to translate a MySQL Table in html -

asp.net mvc - Cannot display error message on Editor or EditorFor -