2,777 Posted Topics
Re: [QUOTE]solve the knapsack 0-1 problem[/QUOTE] Can you explain this problem? The code you posted isn't a complete program. If you expect help, can you post a program that compiles and executes and demonstrates the problem. | |
Re: It happens. They have a name for it: a bug Without the code to demo, who can say what happened. | |
Re: Is this the algorithm for producing the output: Print on each row then the number of $ equal to the row number. Ie 1 on first, 2 on second, etc That implies nested loops, one for the row and one for the row's contents. | |
Re: The case of the letter doesn't matter. What matters is that the spelling of the definition of a variable must match its usage: [CODE] Scanner scan = new Scanner (System.in); // Define a variable name = scan.nextLine(); // use the variable [/CODE] [QUOTE]How can I put everything on one line? … | |
Re: Can you define an array of Strings: String[] anArray = new String[26]; // define array and fill it with the letters of the alphabet? String[] anArray = {"A", "B", .. to "z"); | |
Re: Do you have an infinite loop or a recursive call? How many times does your code loop in the while() loop? What causes/lets the loop end? | |
Re: [QUOTE]I will compile and run the Applet code from the other class with a main method[/QUOTE] There is an interface: JavaCompiler for compiling a java program from within a java program. After the code is compiled and the .class file is available, you can create an instance of the class … | |
Re: That is really interesting. Here's the output from javap for two compiles. The first with the forward reference and the second without. Can't see any difference in what javap outputs. [CODE]class ForwardRefTest { // int a = this.h; // for first compile int h; int a = h; // for … | |
Re: Please copy and paste here the full text of the error message. ![]() | |
Re: Do you understand what the error message is saying? 1) GradeProgram.saveBListener is not abstract 2) does not override abstract method actionPerformed You have coded "implements ActionListener" for those classes but have NOT added the required method for any of them. Add the required method to make the compiler happy. | |
Re: Is this some more of the autoboxing type of help the compiler gives us? | |
Re: [QUOTE]I want it to say false depending if paybackYears is greater than TEN[/QUOTE] Take that statement and extract the variables and the comparison operator and make an expression. Set a boolean to the value of the expression. For example: boolean aIsGreater = (A > B); // true if A is … | |
Re: The First problem is that you have not posted a program that will compile. Can you fix that? | |
Re: What kind of file is your "package"? How is it related to java programming? | |
Re: [QUOTE]I want a java program[/QUOTE] Did you mean: I want to write a java program ... | |
Re: [CODE] int x = (int) (Math.random() * 5);[/CODE] Start on the inside and work out. What does the Math.random() method return? Read the API doc The value returned is multiplied by 5 (*5) That value is then cast to an int: (int) Now read what Ezzaral asked. Slight correction for … | |
Re: What is "selenium tool"? Can you provide a link? How does it relate to java programming? | |
Re: If you can get a clean URL for the image on the site, you may be able to read the image from the site the same as a browser would be able to read it. Some sites require you to spoof them into thinking you are a browser. | |
Re: [QUOTE] how to java path[/QUOTE] Can you explain what you are trying to do? java is not a verb so your question does not make sense. Did you leave some words out? | |
Re: Cross posted at [URL="http://www.java-forums.org/new-java/32441-need-help-timer-java-2.html#post143383"]http://www.java-forums.org/new-java/32441-need-help-timer-java-2.html#post143383[/URL] | |
Re: What are your questions about the assignment that you posted? What code have you written for it? | |
Re: The normal way for a java program to access and write files has nothing to do with whether the code is in a jar. If you can write a program to read and write to a file using files vs resources, that class will work the same if it is … | |
Re: The definition for a class must be on the classpath for the javac or java program to find and use it. | |
Re: The background for what you see is that when the compiler seeing an object item in the println() method call, it calls the object's toString method. The default toString method for the Object class returns: typename@hashcode where hashcode default value is the memory location of the object | |
Re: Where is the image file? Is it with the class file? [QUOTE]they didn't appear on the screen eithe[/QUOTE] What screen? Please explain where you expect to see them. | |
Re: [QUOTE]i want a forward slash "/" in the path[/QUOTE] Run it on linux. It uses the / for separator | |
Re: [QUOTE]what's the "BankAccount" in 'public void embezzle(BankAccount other)' [/QUOTE] 'BankAccount' is the type of the arg passed to the method. To call the method, you must use a variable that refers to a BankAccount object. [QUOTE]Second, How can i add funds from the other account to the other account?[/QUOTE] To … | |
Re: When you have a variable in one class that you want to get the value of in another class, you can add a getter method to the class with the variable and have the other class call that method. A getter method is a method that returns a value. For … | |
Re: Is the ^ underneath the same letter in your posted message as when output by the compiler? [CODE]public BankAccount(String, double, double)[/CODE] I suspect that the compiler was pointing to the list of args to the constructor. All the args need variable names. | |
Re: [QUOTE]no success[/QUOTE] Can you explain what the problem was? | |
Re: A suggestion. Change this: [CODE] System.out.println(array[4-b]); System.out.println(b);[/CODE] to this to put a label on the output vs just having a raw number standing there by itself [CODE] System.out.println("array[4-b]=" + array[4-b]); System.out.println("b=" + b);[/CODE] Where do you show the value of SpacesX? | |
Re: [QUOTE]bizarre two-character EOL[/QUOTE] Line printers printed backwards and forwards. There needed to be a control character to move to the next line directly below the current print head position and not to the head of the line. | |
Re: See the answer posted at [URL="http://www.java-forums.org/new-java/32528-birthday-party-code.html#post143795"]http://www.java-forums.org/new-java/32528-birthday-party-code.html#post143795[/URL] | |
Re: What is the question? To debug your code print out the value of this expression, of each of its sub expressions and of all of its variables: (pieces[rowStart-b][columnStart]==null && pieces[rowStart-b][columnStart]!=pieces[rowEnd][columnEnd] && pieces[rowEnd][columnEnd]==null) | |
Re: Try reading an extra line before exiting the program to keep the console window open until the user enters something. Also its useful in a program that is waiting for input from a user to print a message telling the user what is going to happen. In your program you … | |
Re: To catch all exceptions add a further catch(Exception x) following the last catch you currently have. Please execute the program, copy all of the screen for your test and paste it here. Where does your code test if the user input a 'q'? | |
Re: What code do you have so far? Look at the methods in the String class for checking if a String contains another String. For testing the search algorithm, I'd hardcode in your program a value to search for and leave off getting the value from the user until later. Once … | |
Re: Does it work? Are you getting all the records from the file into the vAccounts Vector? | |
Re: Do you see any pattern for where the 0s and 1s are located in each line? The 1s move in until there is only a single 1 and then they move out. [QUOTE] it is urgent[/QUOTE] Oh. For urgent jobs, that will cost more. | |
| |
Re: Yes, those methods could work provided the contents of points follows the rules. Read the API doc for the methods for what the rules are. | |
Re: [QUOTE]MouseListener to JMenu[/QUOTE] What kind of MouseEvents are you interested in? | |
Re: Also while your are developing the code as James mentioned, add some print statements in the listeners to show the x,y values where the mouse was clicked and moved to. There are different points of reference: to the screen and to the component for example. | |
Re: Try debugging your code to see why the variable in question is set to the values it is by adding print outs to show where it is set and with what values. For example for this: valid1 = !(a<size); add just before that statement printout of ("a=" + a + … | |
Re: [QUOTE]How do I fix this[/QUOTE] Can you describe/document what that statement is supposed to do? To see what values it is testing, print out the value of the expression before the if statement. | |
Re: How about the wait() method? The API doc says: Causes the current thread to wait until ... | |
Re: Do you need help writing an abstract class? Are you getting compiler errors? What textbook are you using for learning java? | |
Re: [QUOTE]my problem..how to show the resulted images when the search button is click[/QUOTE] You need a couple of things added to your code. Definition for the yeahFrame class. Code to create the image. Code to show the image. | |
Re: @tong1 If you are going to feed code to OPs, can you at least add comments to your code explaining the tricks you are doing? | |
Re: Is anyone looking at the OPs code? [CODE]if(deltaX<0 && deltaX<0){[/CODE] This is really careful code. Don't trust just checking it once, do it twice to be sure. |
The End.