Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
366 views
in Technique[技术] by (71.8m points)

How would one go about printing an arraylist in Java (REPL.it) and having my code scan for a particular phrase to perhaps highlight an element?

Let's assume that I have an ArrayList function that is being printed via wordscan. (like such) (yes, this is how it's formatted, sorry in advance. ill make corrections to formatting for those who need it but im not asking for a rewrite, rather a fix)

I want to take the "forEach" variable and prior to the command running have the code go "alright, does the element that contains the (player) variable? If so, it needs to be highlighted)." Any help is appreciated, and corrections can and will be made accordingly.

System.out.print("33[H33[2J");
System.out.flush();
System.out.println(TEXT_GREEN + "WINNER LIST" + TEXT_RESET);
playerScore2.forEach(System.out::println);
System.out.println(TEXT_RED + "LOSER LIST" + TEXT_RESET);
playerScore3.forEach(System.out::println);
System.out.println("");
System.out.println("Do you think you're up to the challenge? (y/n)");```
question from:https://stackoverflow.com/questions/65905981/how-would-one-go-about-printing-an-arraylist-in-java-repl-it-and-having-my-cod

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...