+ 2
JAVA
How to compare String prefix and suffix if an argument is passed to the string ???
5 Respostas
+ 23
You can use startsWith() and endsWith() methods.
String str = "Java is fun";
if(str.startsWith("Java")){
// true
}
if(str.endsWith("fun"){
// true
}
Also look for how to use matches() method in Google. You can compare any substring using this.
+ 5
An example please.
+ 1
Hi meharban my query is if the string has the same prefix and suffix of 3characters then we have to remove suffix in that string.
For example : If string is JAVAJAV it should print JAVA.
another example : if string is LEARNLEA IT should print LEA.
+ 1
If String is LEARNLEA Then it should print LEARN.
Hope u understood now...
+ 1
Yes i got it on by own without google.. i thought till now I'm zero at programming after solving this I'm having confidence by programming skills has improved to 1%