Skip to Main Content

Java Programming

Show number of identical words in number

User_P726MNov 13 2022

Hello together

I have a question regarding a programming and i don't know how to solve it.

I have 3 strings[] which is sensed by the input of a user.

As an example:
Scanner keyscan = new Scanner(System.in);
System.outprint("Team 1 ");
String team1 = keyscan.nextline();
System.outprint("Team 2 ");
String team2 = keyScan.nextline();
System.outprint("Team 3 ");
String team3 = keyScan.nextline();

int identical = 0;

system.out.println(identical);
keyScan.close();

I am trying to get the number of identical names printed as a number.

Example:
team1 contains the following string "Mike, Steve, Steve, Obama". So Steve appears here 2 times. Then the output should simply be 2.

How can I program this?
Thanks a lot!

Comments
Post Details
Added on Nov 13 2022
15 comments
141 views