I have a string like this - "5,password,6099000,tree,city"
.
I want to extract only password
from it. This means anything after first comma and before second comma.
How do I do this?
I have a string like this - "5,password,6099000,tree,city"
.
I want to extract only password
from it. This means anything after first comma and before second comma.
How do I do this?
The easiest solution might be to split the string on comma:
String input = "5,password,6099000,tree,city";
String[] parts = input.split(",");
String password = parts[1];
Use the function Split(),
String example = "5,password,6099000,tree,city";
String[] parts = example.split(",");
System.out.println(parts[1]);
Also look here: How to split a string in Java
String string = "5,password,6099000,tree,city";
String subString = string.substring(2,10);
I assume you are a Java beginner, you may want to check
String Manipulation