1,678 Posted Topics
Re: These are the two important pieces of code: [CODE=Java]public int setCreditHrs() { return creditHrs; } if(!student.setCreditHrs(hrs))[/CODE] Mistakes: 1. As you can see, in the first piece of code, you have declared your method as "public int setCreditHrs()". What this means is that the method returns an int (where it says … | |
Re: IntNode cur = head; IntNode prev = cur; Doesn't make any sense. You're essentially assigning cur = head, then prev = head. Do you mean to say: IntNode prev = cur; IntNode cur = head; ????? | |
Re: @bluerose I think javaAddict conveyed that same point with his post. Please don't repeat people for the sake of posting (unless you're adding something to the discussion), otherwise, you'll become like adatapost. | |
Re: There are also a lot of jobs that are related to computer programming, that you might not think of if you are focusing strictly on coding. Some people here who are in industry might be able to give more examples, but here are some topics to look into: Software configuration … | |
Re: We can't "give" you the code. In a BST, numbers greater than the value of the current Node are in its right child, and less than are in its left child. Therefore, if you're looking for a certain value/Node, just search logically until you hit that Node. Then return it. | |
Re: Linux is an operating system. Java is a programming language. Coincidentally, java should run the same on Windows and Linux (don't count on it) but if this was a C++ program, you would not have the same luck. | |
Re: What does google sidebar have to do with Java programming? | |
Re: pitchTarget = lineScanner.nextInt(); // return the next token as a double targetMap.put(taskNumber, pitchTarget); //this is the line that doesn't work Your first line I posted doesn't make sense. The nextInt() method does not return a double, it returns an int. And your treeMap is declared as taking a K, V … | |
Re: post your main method... | |
Re: To get the size of a file, you use file.length(). This tells you how many bytes the file is. Is that all you needed to know? | |
Re: for (String name: this.students.keySet()) // line 1 { System.out.println("Student " + name + ":"); // line 2 //this line should call the displayMarks() method from the class student, but whatever i try doesnt work System.out.println(); } In order to call a method of the class Student, you must use an … | |
Re: You would just add "\n" to the String you are outputting whenever you want it to go to the next line. Is this even your code? That seems awfully simple to not know for such a complicated piece of code, so maybe I misunderstood your question. | |
Re: No, it does not, because Scanner's hasNext() method does not get the next character, or get anything for that matter. It tells you if the Scanner has any more tokens in its input, and it does not advance past any input. So you'd be sitting in an infinite loop (if … | |
Re: If you want to start a completely new game, then the ideal way would be to have Life set up as a class, and you'd simply create another Object of that class type. Alternatively, you could set all your variables back to blank/however they were initially. But if you're referring … | |
Re: Personally, my first instinct would be to write a listener method that got the text, counted how many characters were there, and "refused to let more be entered" by setting the text back to whatever was previously there if the user entered too much. That would work, however, my first … | |
Re: [url]http://java.sun.com/javase/6/docs/api/java/lang/String.html[/url] What do you think indexOf does? I can't really clear up the problem without knowing what you expect it to do and what it is doing. | |
Re: If you want to read from a file and count how many characters are in it, use FileReader or FileInputStream, not InputStream, since you cannot open a File with InputStream. Then use a while loop like they said, incrementing a counter for each byte you read. The final value of … | |
Re: I don't see how this is a question of what function you are using. Generate a pseudo-random number, then use the modulus operator to force your result to be between 0 and whatever. Then use addition to bring that result between 10 and 20. | |
Re: I don't know that this is the [I]best[/I] way to do it, but why not use a for loop that goes through the String[][] and setValueAt(Object, row,column) to update the JTable. | |
Re: What do you mean "create the box"? Do you mean a button that the user can click on, or do you mean the window in which your content (the pictures saying buy it) is displayed? Look into how to create and use JFrames, JPanels, Layout Managers, JButtons, and JLabels. You … | |
Re: Nobody is going to do your project for you. Either read the forum rules or go away. | |
Re: Did you try calling setSize on the JPanel, then calling getSize afterwards? Also, post your code. | |
Re: How do you plan on using that tool? Looks like more trouble than it's worth. If you have the skill to do this, then by all means. Otherwise code it up yourself. Keep in mind that exchange rates frequently change, so you should not just hard code the current exchange … | |
Re: Judging by the fact that you got the expected output, and not an error, it seems like a safe assumption, doesn't it? If you're concerned about it, run some tests on varying inputs. You'll probably find that it works fine. My guess is that the toLower() function uses the ASCII … | |
Re: [QUOTE=MrDiaz;867636] setValues() takes all the data from the controls on my UI and sets these values to an Object "Day". So each day has the same properties (hours, landings, solo flying, etc.) I think I'm going to use the Java DB. Quick question, how easy would it be to deploy … | |
Hi, I'm a fairly good Java programmer, but I have basically no web development experience. I'm posting in the html forum because I know it is the most basic, but I'm sure there are other necessary tools to accomplish this task, please let me know what they are. I want … ![]() | |
Re: [CODE=Java]boolean validChoice = false; while(!validChoice){ //Get the user's input, if it is y or n, set validChoice to true. }[/CODE] You said you "need exception", do you mean you want to throw an exception? If so there are a few ways you can do that. edit: I just realized you're … | |
Re: If you're asking if you can output the contents of the JTable into the file, then yes, you can. Using two for loops (nested/one inside the other) go through each row and each column and print whats at the index into the text file. Use a PrintWriter to output to … | |
Re: Are you doing a Huffman Coding project? If not, I don't see the purpose of what you're doing. (In other words, if you aren't doing Huffman Coding, then what do you mean by 'chunk the file bytes into a certain size before writing'? .... I don't see how you'd know … | |
Re: Read the forum rules. We only give homework help to those who show effort. Ask specific questions about problems you are having with your code and you will get help. Otherwise, you will not. | |
Re: [Warning: This is coming from a Java programmer with no C++ experience] Assuming that clicking 'X' generates an event, and C++ has method overriding - override the method that closes the window when the user clicks 'X', and do nothing in that method. That way, nothing will happen when the … | |
Re: [QUOTE=K?!;868009]I didn't know how to access the class held another class, from that class that is held. [/QUOTE] That does not make any sense. Try to clarify? [QUOTE=K?!;868009]The problem now is, when users start working in the program(switching from one panel to another), it keeps on adding panels to the … | |
Re: @ thoughtcoder Profound :yawn: . Next time before you post, try removing any arrogant or insulting language from it. Especially when jbennet has contributed much more to this site than you have. | |
Re: As hard as I tried, I couldn't find anywhere where you told [I]us[/I] where the problem is. Since we can't read your mind this might be useful information. | |
Re: [QUOTE=evant8950;864347]I'm working on a program to upload some files to an ftp. I created a thread the starts the upload when the upload button is pushed. When the upload button is pushed the GUI freezes because it is uploading. What change would I have to make to get the GUI … | |
| |
Re: Use code tags and only post relevant code. I doubt that those huge tables of data are relevant. Your question also doesn't really make sense. What does "stop and wait timeout resend" mean? | |
Re: int value = JOptionPane.showMessageDialog(null,"blah"); if(value == JOptionPane.CANCEL_OPTION){ //do stuff } | |
Re: In your paint() method, call super.paintComponent(g). It will clear the screen. Alternatively, you could use this piece of code from inside your paintComponent method: [CODE=Java]g.clearRect(0, 0, this.getWidth(), this.getHeight());[/CODE] | |
Re: You could also use a stack to reverse the order. Put them in a stack, then pop them, and for each pop, put the element that was popped into an array. The array you end up with is the original one but in reverse order.... | |
Re: Post all *relevant* code. You definitely need to have implemented some sort of action listener for the check boxes to even begin making this work. Did you do that? | |
Re: @OP ignore this, I am asking a question relevant to this thread rather than giving you advice here. . Searching each generated word with a long list of existing words (which might be in thousands) is itself a time consuming task, but you can have the dictionary words put into … ![]() | |
Re: For the first error, you're either using a constructor that does not exist, or you didn't properly import the class. | |
Re: If you must, cast each element individually to the appropriate type. [CODE=Java] public static void main(String[] args) { Object[] ints = new Integer[10]; ArrayList<Integer> list = new ArrayList<Integer>(); list.add(1); ints = list.toArray(); System.out.println((Integer)ints[0]); }[/CODE] | |
![]() | Re: Why don't you just use the normal way to associate an image with the button? [url]http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JButton.html[/url] ![]() |
Re: // is the bucket in the table? I don't know, is the table round? // can it be added to the table? Perhaps. // can the bucket be added at its hashed index? If there's nothing else there, why not? // what is to be done if the hashed index … | |
Re: Without looking at your code, (gotta be somewhere soon) I'd recommend that you use compareTo to compare the two Dates to each other. If you aren't using the Date class to store your dates, look at the compareTo method for whatever class you're using | |
Re: [url]http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html[/url] You would follow the same process as shown there, except create two client sockets instead of one. Then send the same output to both clients whenever it is necessary. |
The End.