7,116 Posted Topics
Re: EXACTLY what code are you executring and EXACTLY what is thet COMPLETE error message? ps Did you intend that line 9 will create a *new* "NumberArray" variable? The NumberArray that you initialise in setNumberArray isn't the one declared on line 5! | |
Re: You can use `System.setOut(PrintStream out)` to send all your console output to a file instead of the console, without having to change any other code. | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: That's not enough info for anyone to understand where or why you are having difficulty. How far have you got - is there any code or documented design yet? Have you got as far as pushing each non-terminal node onto a stack and popping it when you finish processing its … ![]() | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: Which part is the problem? Is there really nothing in the {}? How is the class Song declared? | |
Re: > To access the kangaroos, you simply use getKangaroos(). What exactly does that return - is it a Kangaroo object? If so, what attributes/methods does that support? | |
Re: You need to create some `new` instances of TelephoneDirectory, then use them to call all the methods and print the results to see if they are correct. ps: TelephoneDirectory is a very bad name for this class. Instances of the class represent single entries in some directory. A class called … | |
Re: So there we have 698 lines of highly technical code with zero useful comments and no specification, and we are supposed to know why it doesn't do what you expect. You *may* be lucky, but I suspect that you are looking for far too much work from us here. | |
Re: I tried your fxml file in Netbeans/Java8 and it loaded OK and diplayed a (slighly wonky) calculator-type screen. No errors. Maybe you have an old version, or a mismatch between the layout editor and the compiler versions??? | |
Re: It looks like the problem is with the arrays you are using, noy how you print them. You create a 2d memberNames array that looks like it should have one row for each family and member names for that family in the row, but its an array of ints, not … | |
Re: Here's a less esoteric example that is used all the time in image processing... a common way to store a pixel is an a 32 bit int, with the red, green and blue values each occupying one byte of the int. Here's how you extract those values: int r = … | |
Re: stultuske was right until last month. The latest version of Java (Java 8) allows static methods and "default" instance methods to be defined in interfaces, which are inherited by any class that implements the interface. | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's an insult to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: Strings are supported as a special case in the compiler and are very highly optimised. The fact that they are immutable allows all kinds of optimisations that are not possible for mutable objects, especially in a multi-threaded environment. | |
Re: APU doc says > public boolean add(E e) > > Adds the specified element to this set if it is not already present. More formally, adds the specified element e to this set if this set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set … | |
Re: Spend what time you do have learning about arrays and forget trying to finesse extra credits. If you don't understand arrays you certainly won't get any further anyway. | |
Re: For OS internals, drivers etc C++ definitely. Java is for applications - it deliberately isolates you from all the low-level OS stuff. | |
Re: "might exist in the JavaFX APIs but I don't have those installed here" That's very worrying from a security viewpoint. JavaFX is included with Java 7 update 6 and all later versions. | |
Re: a and b are reference variables. The == operator for references tests if those two references are equal - ie that they both refer to the same object. Read the API doc for the String class, specifically its `equals` method. | |
Re: That implies that `last` is null when that line is executed, as only the `last.next` expression will generate an NPE. That would be the case if the while loop on lines 44-48 was executed zero times (and maybe under other circumstances as well). | |
Re: Did you execute that code? I thought not. Try running it - it *does* generate the output `they are equal` It looks like you are asking the wrong question. | |
Re: Just google for it. The WikiPedia article on "event driven architecture" has a section specifically about Java Swing GUIs | |
Re: Start a loop Print the menu using System.out.println Get the user's input using a Scanner if the input was "exit" then break out of the loop use a switch to invoke the appropriate action (end loop) See http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html | |
Re: Java support for media has beena shambles inthe past - JMF never worked properly. The good news is that JavaFX is now a standard component in all the current versions of JavaSE. JavaFX has excellent support for media. See this recent thread - especially the last two posts http://www.daniweb.com/software-development/java/threads/475808/how-to-play-mp3-files-in-java-using-eclipse | |
Re: There's a much simpler solution that stultusk's - no need for two arrays or sorting Remember that chars in Java are integer values, and the alphbetic letters are represented by consecutive values, so you just need one array to hold the counts. For each letter in the input: .. convert … | |
Re: Same as searching any other list. Start with the first entry, use a loop to check each entry to see if it's the one you want. | |
Re: Because that's not a recursive solution? | |
Re: Yes, 1.6 is no longer supported, and security bugs in 1.6 are not fixed any more. It's ***essential*** that you update to a supported version - 1.8 or the latest 1.7 | |
Re: Look at your initial value for minDistance. Do you think you will ever find a smaller value than that? So the if test on line 10 will always be false. Start minDistance at some very large value (larger than any distance you will calulate) Integer.MAX_VALUE would be the obvious choice. | |
Re: No, no, not an idiot. We've all done that, or something like it. | |
Re: In your method you are passed an instance of `f` and you need to access that instance's value of `number`. How you do that depends on how the class `f` was written. If its number field is public then you can refer to it like this public void someMethod(f someF) … | |
Re: You only need one Scanner. You don't need an Iterator to use a Scanner. Before posting code here, compile it and deal with as many of the compiler errors as possible before asking for help. You were asked to implement a new data type ("class" in Java), and you have … | |
Re: Centering things is a responsiblility of the layout manager. Have a look at [this](http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html) and chose a layout manager that handles sizing & centering the way you want. Note also the the frame has a layout manager that positions the panels, but the panels have their own layout managers (not … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: (Edit) deleted text of post that was based on an incorrect reading of sepp2k's post. My mistake. He is right. | |
Re: > The player would be moving, so how would you determine which object is the closest since you wouldnt just want to check if the player is colliding with all other objects? Checking for rectangles overlapping is so quick & easy that you may as well just do it for … | |
Re: You can use parens to control the order of execution, eg ((a && b) || (c && d)) | |
Re: Simply test for a -1 selected index before trying to use it! | |
Re: "an annoying error something with Scanner method" It would be a lot more helpful if you gave us the exact complete error message, including the all-important line number(s) (edit: this post should have appeared before the previous one!) | |
Re: What exactly are you saying here? Sounds like "I don't like any of the tutorials on the web, so write one just for me"? Anyway - you don't need to worry about make files for this simple example. Just compile all your classes with javac.exe, run the server and run … | |
Re: Helpful info, but maybe a bit late? (Question was asked 2 years ago!) | |
Re: I don't know of any simple solution. You may have to create a tiny class with the data value and its original index as its two instance variables. Then you can sort an array of those objects on the data value, but still retrieve their original indexes. | |
Re: <Order extends Queue<Order>> looks wrong (?) How can Order be a subclass of Queue<Order> ? | |
Re: Questions: Why have a whole HashMap implemetation just to find enum values from their "f" String. Since enums usually have a small number of values you could simply search `Foo.values()` for a match (with the option of a case-insensitive search if you want) And why the extra code for lazy … | |
Re: Your methods need to return a boolean (true or false) not a String if you want to call and use them like you do in lines 14 and 16. The String class has methods `equals` and `equalsIgnoreCase`. You can find the details in the Java API documentation [here](http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true) For example: … | |
Re: for (File afile : files) { if (afile.isDirectory()) { this.childFolder = new Folder(afile); parentFolder.add(childFolder); } recursiveTraversal(afile, this.childFolder); } If the first n Files are files (not directories) the variable childFolder is noy set and presumably inherits some left-over value from a previous class? ps: This kind of thing is much … | |
Re: YOu can use the jvisualvm profiler that comes as standard with the JDK - you'll find it in your JDK bin folder. It's really easy. | |
Re: "It doesn't work" tells us nothing. Did you get an exception? Was the file created but with the wrong location and/or name? Etc? The exception on line 22 (catch) contains details of any errors. It is a bad mistake not to use that. Add an `e.printStackTrace();` inside the catch clause … |
The End.