Bye,
Nicola
Nicola Garofalo wrote:Hi Nick,
forget your method arrayList(), it's completely wrong, delete it.
For example you could write a method that receives a List as a parameter, performs the sort and prints it out.
Bye,
Nicola
Nicola Garofalo wrote:You have a list that can be sorted. Do it in one or two methods, as you prefer, but why should you convert it to an array?
Bye,
Nicola
David Newton wrote:* Please try to normalize your indentation and make sure any comments actually communicate something useful: the "why", not the "what". For example, I already know that the "import" statement imports Java libraries.
* Comments for classes and methods, when necessary at all, should follow standard Javadoc conventions rather than using the double-slash notation.
* Please PostRealCode -- as written this code won't compile. This adds a layer of aggravation for folks who prefer to look at Java code in an IDE (so we can format it rationally :)
* Remove the infinite loop.
* All of your functionality is in the constructor--this won't "return" anything, as its comment claims. A constructor will just return a new Find--consider putting the code that actually *does* something into an instance method, then calling that method. Perhaps with a file name as an argument (it could also be a constructor argument; whichever).
Particularly when requesting help from others, it's nice to make things as easy for us as possible.
Bye,
Nicola
Nick Rowe wrote:Apologies, i try to keep my comments to one line and simplistic in my posts to save space and people the trouble of reading.
printOrderedList method which is returning the list as an integer
Bye,
Nicola
Bye,
Nicola
Nicola Garofalo wrote:In the example i asked you to test, you print the arrayList, the entire one, outside the loop, after it, once the html file is completely parsed line by line.
The method find filters all the lines. If there's no line that matches your pattern your ArrayList may be empty, thus your output could be empty.
Bye,
Nicola
Bye,
Nicola
Nicola Garofalo wrote:Yes, remove it. I guarantee, nothing bad is going to happen
![]()
I get the following output if i save your code in a file called my.html placed in a folder of my filesystem, and if i execute your application.
The output,as expected, is made of one element, because one is the line that matches your pattern.
Bye,
Nicola
Nicola Garofalo wrote:Oh, really no problem Nick.
Well, once the file is compiled you should execute the program. You are missing the funny part![]()
Now find in your file system the file Find.class generated by the execution of your javac command
As you wrote the class it should be in the same folder of your Find.java file
then execute the command
see what happens and let me know
Bye,
Nicola
Nicola Garofalo wrote:Not
But
Exactly as i have written it
Bye,
Nicola
Nicola Garofalo wrote:Go to the the directory where your Find.class file is.
Then type
java -cp . Find
Bye,
Nicola
Nicola Garofalo wrote:
type java then space the -cp then space the . then space then Find
Bye,
Nicola
Bye,
Nicola
Bye,
Nicola
Consider Paul's rocket mass heater. |