How can I print part of String in Java? e.g.: The string is "Application No: ABCD" and I just want to print only ABCD?
Asked
Active
Viewed 101 times
-3
-
5substring it, replace the beginning, probably use regex. There are multiple ways – SomeJavaGuy May 09 '17 at 05:22
-
6Have you tried something yet? More important, did you spend any time researching this before posting to Stack Overflow? – Tim Biegeleisen May 09 '17 at 05:24
-
2Would be faster to use a search engine than sign up to SO, post question and wait for answer. Plus you'd feel like you have learned and achieved something. – dat3450 May 09 '17 at 05:25
-
1Possible duplicate of [How to print only specific parts of a string in java?](http://stackoverflow.com/questions/23019070/how-to-print-only-specific-parts-of-a-string-in-java) – Pawel Gradecki May 09 '17 at 08:43
-
1Possible duplicate of [How to split a string in Java](http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java) – aUserHimself May 09 '17 at 11:14
1 Answers
0
You can split te string from ":",
String yourstr = "Application No: ABCD";
String[] words= yourstr.split(":");
System.out.println(words[1]);

AnjuT
- 166
- 1
- 4
- 17