Uness you use the -ea tag when executing the code, those assertions don't do anything.Stan Austin wrote:Haha, im not sure what assert even does, but they are there. and i've just ignored them.
Does it really? I can see several compiler errors in it.. . . this code just runs on no compiler errors. . . .
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
![]()
Carey Brown wrote:This is your culprit
i = i++
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.
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.
Stan Austin wrote:Hopefully this is much better formatting. i am using netbeans Formatting here and have created it as it's own little program not an excerpt of the bigger thing, so hopefully that helps.
Any pointers on this?
No.Stan Austin wrote:is this person[].size?
Did they choose the course or did you? Maybe have a quiet word with your line manager and suggest a different choice of course might be beneficial for staff in future.Stan Austin wrote:. . . My course is sponsored by my employer . . .
Lots of people say that. It is a bit like saying, “I'll check my oil and tyre pressures when I have a bit of time.” I know people who ended up with an enormous garage bill by doing that. You should be indenting your code from the word go. The amount of effort that takes will be overwhelmed by the confusion you get when incorrect indentation obscures one of your mistakes. Remember: you are the person who most needs to find your mistakes and you are probably also the person who needs the most help finding mistakes. Also, you can set up options on your text editor that will make the process much easier. Look at the three links in this old post of mine.Stan Austin wrote:. . .
Liutauras Vilda wrote:And yes, indentation a bit better, not ideal yet, but better
Thank you i will work on this once my schedule clears up abit. . . .
Oh good. It wasn't too difficult to navigate the API documentation when it contained 2000 classes but now there are about 4200 of them, it is hard work even finding the name of the class.Liutauras Vilda wrote:. . . From Java 9 there should be a nice search function in the API website . . .
All things are lawful, but not all things are profitable.
Knute Snortum wrote:Can you post your complete code with proper formatting?
Liutauras Vilda wrote:
Knute Snortum wrote:Can you post your complete code with proper formatting?
@OP
I've spent a good amount of time looking for this link http://javaranch.com/style.jsp
Allocate one evening studying it (with all sub links) so you'd understand importance of it and wouldn't make formatting and indentation errors again.