202 Posted Topics
Re: No one here will write code for you. You need to ask a more specific question. What is it you are having problems with? Choose one issue to ask about at a time. If you have a question on a different topic, then start a new thread. | |
Re: You only have one loop, but I think you need two: One loop goes over each character in the input, converting letters to numbers. Another loop is needed to see if the user wants to keep entering more numbers by checking for the '#' character. The first loop should be … | |
Re: The purpose of getters & setters is to hide the implementation of a datatype from the "user" (usually another programmer). If I write a class, I usually need a way to allow you to set up the data the way you want, but I don't necessarily want you to know … | |
Re: [URL="http://www.daniweb.com/forums/thread99132.html"]http://www.daniweb.com/forums/thread99132.html[/URL] | |
Re: If you post your code in code tags, it will appear with line numbers. That helps in determining where the problem occurs. The way you are trying to initialize your arrays in Maze1 and Maze2 won't work. Try this instead: [CODE] class Maze2{ String structure[][] = { {" ", "1 … | |
Re: On line 7 you are trying to add the contents of your 2D array (which is empty), when JamesCherrill suggested you just add row+col. Try changing line 7 to store the sum row+col in your test variable. | |
Re: Not sure what other class you're talking about, but as to your second question, replace ??? with amount. If you post code again in the future, please enclose it in code tags. | |
Re: Please post your question again but put your code in code tags, and print the text of the error message you are getting. | |
Re: Looks like maybe you could change line 75 from [CODE]public void gameLoop()[/CODE] to [code]public static void main(String[] args)[/code] | |
Re: You cannot decrement the size of the array. Arrays have a fixed size in Java. If the size of the array must remain accurate to the content, you could create a new array and then copy all but the deleted element from the old array into the new array. Note … | |
Re: I'm not familiar specifically with Apache Derby, but usually when you download a JDBC driver, there's a jar file which you need to put in your classpath. Did the file you downloaded include a jar file? Did you put the jar file in your classpath? | |
Re: You need to implement either Comparable or Comparator. Look up Arrays.sort in the javadoc and you will find links to these. | |
Re: It looks like you have an extra closing curly brace just before the line you've highlighted in red. Try to remove that one. Next time, please post your code inside code markers. Also, if you use an IDE like eclipse, that will help you match up your {'s and }'s. | |
Re: Constructing an array of objects in java is a 2 step process. First you create the array of references. Then you must construct the actual objects. You have skipped the second step. You only have an array of references, but the references don't point to actual objects. You can not … | |
Re: I am not getting the same error you are, but my simple TCP client/server program does not work in a single instance of BlueJ. However, if I run BlueJ twice, then I can run the server in one instance and the client in the other and that works. | |
Re: The syntax for comparing a string to several values to see which one matches is something like this: [CODE] if (input.equals(value1)) { // handle value 1 here } else if (input.equals(value2)) { // handle value 2 here } else if (input.equals(value3)) { // handle value 3 here } // ... … | |
Re: To time how long some process takes you can use an algorithm like this: 1. set a "start" variable to System.currentTimeMillis() 2. do whatever it is you want to time 3. set a "stop" variable to System.currentTimeMillis() 4. calculate an elapsed time by subtracting the start time from the stop … | |
Re: What about MyStack? Presumably it implements the push and pop methods, right? If so you need to call pop from superPop, and call push from superPush. | |
Re: Here are some links which might help. [URL="http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/"]http://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/[/URL] [URL="http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o"]http://stackoverflow.com/questions/487258/plain-english-explanation-of-big-o[/URL] [URL="http://en.wikipedia.org/wiki/Big_O_notation"]http://en.wikipedia.org/wiki/Big_O_notation[/URL] | |
Re: When you add an action listener to some object (like a button), the object that you add must implement the ActionListener interface, which contains one method called actionPerformed. The way this works is when you click a button, the JVM will notify any "interested parties" of the event, meaning it … | |
Re: Have you tried a google search? | |
Re: According to [URL="http://www.javaworld.com/javaworld/javatips/jw-javatip24.html"]this web site[/URL], you need to import the sun.audio package. Haven't tried this myself, but maybe you can get it to work? Here's another [URL="http://download.oracle.com/javase/6/docs/technotes/guides/sound/programmer_guide/contents.html"]resource from Oracle[/URL] that's much more in-depth. Here's one more [URL="http://www.dreamincode.net/forums/topic/14083-incredibly-easy-way-to-play-sounds/"]link[/URL] which may help. BTW, my search terms in Google were "java add sound … | |
Re: I had to add 2 lines to Cliente.java: [CODE] package mensajes; import javax.swing.*; [/CODE] Then the code compiled & ran. I did not see the errors you mention above. | |
Re: What exactly is your question? How do you run the class above when it doesn't have a main? BTW, your code tags worked perfectly. | |
Re: If you are trying to read input from the command line, check out the Scanner class in the Javadoc. If you want a GUI, look up JOptionPane. In either case, when you get a string of input from the user, you can check in a loop whether each character in … | |
Re: See [URL="http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html"]http://download.oracle.com/javase/tutorial/uiswing/components/editorpane.html[/URL] | |
Re: There are 2 key ideas in recursive algorithms. The first is the problem must be something that can be broken down into simpler steps in an iterative manner. The second is the iteration must have a well defined stopping point. Factorial is a common example because it has a "natural" … | |
Re: Change line 26 to [code] this(species, autumnColor, price); [/code] Also, there's no need for the check on lines 27-28, since a boolean can only be either true or false in Java. There is no other possible value it can be. | |
Re: Yes, I think your formulas are incorrect, since the program calculates a negative balance after about 14 years. :) You can get the program to pause using Thread.sleep(n);, where n is a number of milliseconds, rather than asking the user to hit a key. This needs to go in a … | |
Re: When you catch an exception, print out the stack trace using ex.printStackTrace(). Then put the results here so we can see what's going wrong. | |
Re: You are missing a close statement after writing to the grades2 object. | |
Re: According to your comment, hasNext() is supposed to return true if there are more elements in the list, but the code returns true when cursor.next == null. Isn't that backwards? Also in next(), you check if hasNext() is true, then you say there is no such element. This also seems … | |
Re: Try changing line 12 to [CODE]private desPanel des=new JPanel();[/CODE] | |
Re: If you use FlowLayout and the container is wide enough, both text fields will appear in the same row. You either need to make your container more narrow so the next text field will appear in the next row, or use a different layout manager. Probably GridLayout would be the … | |
Re: Too vague. You need to ask a more specific question. | |
Re: I'm not sure I understand what you are asking for, but if you want some practice coding in Java, try this site: [URL="http://codingbat.com/java"]http://codingbat.com/java[/URL]. | |
Re: Have you tried System.arraycopy() ? | |
Re: On line 15 your are using an assignment rather than a comparison. Change = to ==. | |
Re: Since MPanel is not complete, and you haven't included your main game class, I created a tester and just put your scoreBoard panel on a JFrame. Everything seems to be working fine. So I also added a button to try to update the scoreBoard like you're doing in MPanel, and … | |
Re: To convert an integer to a String: [CODE]int x = 1234567; String str = "" + x;[/CODE] Look up charAt in String class documentation for extracting individual characters from a string. | |
Re: I don't understand what tong1 was trying to say, but you cannot overload a method in java by changing the return type alone. Overloaded methods must have different parameter lists (and it is the datatypes that count, not their names). So for example, public void f1(int n) and public void … | |
Re: What are your goals? Why are your learning Java? What do you want to know? | |
Re: You probably already know if you had the File object, you could recreate the Scanner and that would reset the pointer to the beginning of the file. But since you don't have that, you need to rethink your loops. Can you think of a way to combine both checking for … | |
Re: Have you tried adding a row to your table model? See [URL="http://download.oracle.com/javase/tutorial/uiswing/components/table.html"]http://download.oracle.com/javase/tutorial/uiswing/components/table.html[/URL] for some help. | |
Re: This forum is not a place where people will write code for you. You need to ask a more specific question. Your question is too vague/broad so no one here is going to be able to help you. | |
Re: This is because your while loop says while (true), and the only place where you break out of the loop you "return" from main. Either change the condition of the loop using your stop variable, or change the return statement to a break statement, which will just break out of … | |
Re: In java you can create a label to use with loops, break & continue statements. See [URL="http://www.janeg.ca/scjp/flow/labels.html"]http://www.janeg.ca/scjp/flow/labels.html[/URL] for an example of how this works. The syntax for creating a label is an identifier, followed by a colon. Then remember that single-line comments in java start with //. So the code … | |
Re: It looks like you are mixing up where to do error checking. To fix this you should move String host=(args.length<1)?null:args[0]; into main before you create your new ChatClient, and then pass host into the constructor instead of args[0]. But you also need to be careful about the order of your … | |
Re: Here's an algorithm that should help. 1. Put digits into an array. E.g., int digits[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 2. Write some code that generates 2 random numbers between 0 & 9. Store the random numbers in 2 variables, say num1 and num2. … |
The End.