Menu
Question Index
...


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

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

class GetFriendsOfPerson

{    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 List<String> getFriends(String friendsDetails, String personName) {
//Write code here to get the list of friends of a given person.
}
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App