Please consider following code:
public static void main(String... args) {
int count = 0;
Pattern pattern = Pattern.compile("X");
Matcher matcher = pattern.matcher("5\\yeyyyyyyy");
while (matcher.find()) {
count++;
System.out.println(matcher.start()+"..."+matcher.group());
}
System.out.println("The total number of occurrences "+count);
}
1) If I write x=5 in above program then I get following output:
0...5
The total number of occurrences 1
So I got information that 5 is at 0 index and it is only one time in the given string.
2) Similary We know that // is at 1 index and it is only one time in the given string. How can I get this as output?
I am trying to write
x=//
I am getting compile time error.
I hope I made you guys understood of my point. Thanks
Aucun commentaire:
Enregistrer un commentaire