This question already has answers here:
How do I compare strings in Java?
(23 answers)
Closed 7 years ago.
I've used
String[] red = linija.split("(?!^)");
and now in this String array I want to know if red[0] is "/". Tried (red[0] == "/") and with "//", please help.
Have you tried red[0].equals("/") ?
Related
This question already has answers here:
Best way to concatenate List of String objects? [duplicate]
(19 answers)
Java: convert List<String> to a join()d String
(23 answers)
Closed 2 months ago.
I have list with some values:
List<String> list = Arrays.asList("1","2","3");
I want convert it to String "1; 2; 3"
I have only idea with loop. It works but it doesn't looks elegant. Maybe somebody can advice more easy way to do it?
Try to use String.join("; ", list)
It should work
This question already has answers here:
"’" showing on page instead of " ' "
(12 answers)
Closed 1 year ago.
I want to convert ’ to apostrophe(') in Java.
Input:
String s = "master’s degree"
It should be:
master's degree
s = s.replace("’","'");
This question already has answers here:
How do I decompose a URL into its component parts in Java?
(5 answers)
In java, what's the best way to read a url and split it into its parts?
(5 answers)
Closed 3 years ago.
I have couple of URL's like
http://toidsu.abc.tnd:9083/login/pages/selection.xhtml#
http://toifsmdu.abc.tnd:9081/login/pages/selection.xhtml#
I want to get string up to 'http://toidsu.abc.tnd:9083' and 'http://toifsmdu.abc.tnd:9081'
How to do it?
Use this class to parse it for you: java.net.URI
This question already has answers here:
How can I pad an integer with zeros on the left?
(18 answers)
Closed 5 years ago.
What does it represents in java?
String.format("%01000d",0)
It prints 0 thousands times. But can anyone help how does it actually works. What does "%01000d" represents?
The first argument is a format string, here you can find the sintax:
https://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html#syntax
This question already has answers here:
How to evaluate a math expression given in string form?
(26 answers)
Closed 6 years ago.
I have a equation in string format like "45+5*4-6" which I have to solve in Java.
Is there any way to solve equation which is in string format?
Check Beanshell
Something like this should work -
Interpreter ip = new Interpreter();
ip.eval("res = 45+5*4-6");
System.out.print(ip.get("res"));