Ask Experts Questions for FREE Help !
Ask
    siccoblue's Avatar
    siccoblue Posts: 1, Reputation: 1
    New Member
     
    #1

    Apr 21, 2017, 04:52 PM
    Completely new to java, trying to figure out how to implement this code properly
    I'm trying to implement something at the moment and am having issues doing so properly


    So what I'm trying to do here is add this


    Code:
    	public static Player getPlayer(String name) {
    		for (int i = 0; i < Config.MAX_PLAYERS; i++)
    		{
    			if (players[i] != null && players[i].playerName.equalsIgnoreCase(name))
    			{
    				return players[i];
    			}
    		}
    Into this


    Code:
    public static Player getPlayer(String name) {
    		return Arrays.stream(players).filter(p -> p != null && p.playerName.equalsIgnoreCase(name)).findFirst().get();
    		
    	}
    I've tried just flat out replacing it but eclipse doesn't like that and tells me I need to return the type of player, but I have no idea what that means, how can I implement these together without breaking my code?

    I hate to ask for spoonfeeding me but could someone also explain the process here for making it work properly? I'm trying my best to kind of learn as I go

Check out some similar questions!

Method to calculate average in java not working properly [ 1 Answers ]

I am trying to call in a method to calculate average from data that has been input in an array using the scanner class, but somehow the average formula is not working properly. I have tried correcting it for a long time but the output looks something like " args) { //Declare variables int...

Java Code Help [ 1 Answers ]

What is the output of the code below? for (int I =1; I<5; I++) { for (int j=1; j<=i; j++) { System.out.print("* "); } System.out.println();

Java questions. Implement a class, Numerical, to perform the computations described [ 4 Answers ]

Java questions. Implement a class, Numerical, to perform the computations described below. • int sumTo(int m, int n), where m 6 n, to calculate m + (m + 1) + (m + 2) + · · · + n. e.g. sumTo(1, 10) =55,

Need help for java code... [ 0 Answers ]

Method called printGraph() that takes as a parameter an array of integers. Each integer will be between 0 and 100. The method should print a horizontally oriented bar graph of the values, using ‘=’ characters to produce bars. Each value should be divided By 10 and that many equals characters...

I want the java code please [ 2 Answers ]

Write a program that ask from the user how many integers you want to read then reads the set of integers from user, and then finds and prints the sum of even valued and odd valued integers . And also count how many even was entered by user and how many odd were entered by user.


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.