Menu
Question Index
...


Write a program to get the list of friends and friends of friends of the given person.

Input (String, String) (For display purpose new line is shown as $) Output (Set)
Ravi,Lokesh$Ravi,Venkatesh$Ravi,Swetha$Swetha,Narayan$Narayan,Lakshmi$Lakshmi,Divya$Divya,Narayan$Ram,Divya$Sanjay,Ravi$Lokesh,Sanjay
Person Name = Ravi
[Venkatesh, Narayan, Swetha, Sanjay, Lokesh]
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
Person Name = Raju
[Rani, Vikram, Abhijeet, Ramana, Tejaswini, Rajesh, Saranya]
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
Person Name = Mahesh
[]

class GetTheListOfFriendsOfFriendsOfTheGivenPerson

{    public static void main(String s[])
    {
        String input = "Raju,Rani\nRaju,Vikram\nRaju,Abhijeet\nAbhijeet,Rajesh\nRajesh,Saranya\nSaranya,Tejaswini\nTejaswini,Manish\nSaranya,Ramana\nRamana,Raju\nTejaswini,Rani";
        System.out.println("The friends of Rani are : " + getFriends(input, "Rani"));

    }


public static Set<String> getFriends(String friendsDetails, String personName) {
//Write code here to get the list of friends and friends of friends of a given person
}
}
//If required, write any additional classes here

Doubts

Problems

Topic: Collection Framework In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App