Liutauras Vilda wrote:1. Another observation. If from the command line arguments you get an array of names, you don't actually need the loop to put everything to 'person' array.
You can simply do: String[] person = args; In fact, you don't even need that, you can pass just 'args' to your method.
Liutauras Vilda wrote:2. Going further. You don't need to pass argslength as an argument and have it as a paremeter in longest_name() method, as you can identify that from the already passed array. Less arguments - better.
Liutauras Vilda wrote:3. Method name longest_name isn't conventional, it supposed to sound 'longestName'.
Liutauras Vilda wrote:Q: What are you trying to achieve with this line of code?
I understand what this line technically does, but what are you trying to achieve with this in general?
As well as you have such line:
This is something uncommon, verify you understood correctly given requirements.
Liutauras Vilda wrote:I think lines of your posted code are not in synch with what you have in your Netbeans, presumably because you have posted just a snippet of code. In different words, error occurs at line 24 as compiler says, but we don't see here that line 24.
Liutauras Vilda wrote:Line 20 in the posted code contains compiler error too, you can't pass 'person[]' like that. That shouldn't have '[]'.
Liutauras Vilda wrote:And yes, indentation a bit better, not ideal yet, but better
Liutauras Vilda wrote:Somehow I feel you need organize yourself a bit more. Problem is in my opinion, that you solving this exercise in a trial and error way. Randomly trying things and expecting to see if it works - that is usually not a good way, at least not so efficient, so you shouldn't expect quick results.
Liutauras Vilda wrote:Try to read some literature on relevant topics, so you'd feel a bit more confident. There are Oracle tutorials (google for it), could learn a lot from there.
Carey Brown wrote:This is your culprit
i = i++
Liutauras Vilda wrote:Your code indentation is terrible. And you should have spent 2 minutes on fixing that before you post. No excuse, at all
![]()
Campbell Ritchie wrote: I think that suggestion will do what is required of you. Why not post the code as it really should be, rather than messing up the method names?
Campbell Ritchie wrote:What is wrong with line 33? It looks all right to me. I suggest you go through the documentation for (System.out).println() and keep following the links untill you find what method is called in the argument object.
Campbell Ritchie wrote:
Did you only have an equals method? In that case it has been overridden incorrectly; if you look here, you will find out that you must override hashCode() too.
Paul Clements wrote:
Do you understand this code and output?
Paul Clements wrote:
Stan Austin wrote:however if i try to print "Employee.salary" it tells me salary is private!
Yes. That's called "encapsulation". It means keeping instance variable private and only allowing manipulation though the classes own methods i.e. what are commonly known as setters and getters. The getter on 'Salary' is salary(). Therefore if from within manage. java you create an Employee instance called e1 then e1.salary() should return what's held in 'Salary'.
Paul Clements wrote:Stan, keep it simple. One step at a time i.e.
...
Build slowly on something which works. Don't get lost thinking too far ahead.