String[] args
Sun Sep 25 2022 02:48:48 GMT+0000 (Coordinated Universal Time)
Saved by
@cruz
#javascript
import java.util.Arrays;
public class Newsfeed {
String[] topics;
public Newsfeed(String[] initialTopics) {
topics = initialTopics;
}
public static void main(String[] args) {
Newsfeed feed;
if (args[0].equals("Human")) {
//topics for a Human feed:
String[] humanTopics = {"Politics", "Science", "Sports", "Love"};
feed = new Newsfeed(humanTopics);
} else if(args[0].equals("Robot")) {
//topics for a Robot feed:
String[] robotTopics = {"Oil", "Parts", "Algorithms", "Love"};
feed = new Newsfeed(robotTopics);
} else {
String[] genericTopics = {"Opinion", "Tech", "Science", "Health"};
feed = new Newsfeed(genericTopics);
}
System.out.println("The topics in this feed are:");
System.out.println(Arrays.toString(feed.topics));
}
}
content_copyCOPY
Comments