1,963 Posted Topics
Re: We'll be happy to help anyone by giving ideas for their algorithm or debuging some part of the code, but don't expect for someone to read your entire code in order to figure out what is wrong when you the only comment you have made is saying that the code … | |
Re: Put it wherever you want, as long as you say in your code where is it so you can read it: props.load(new FileInputStream("dbConnection.properties")); When you make changes in your .properties files, you must restart the server | |
Re: To start with the class's constructor is wrong declared: Right way: [CODE] class SomeClass { public SomeClass() { } } [/CODE] Wrong way: [CODE] class SomeClass { public [B]void [/B] SomeClass() { } } [/CODE] | |
Re: I think that the concept of the query is wrong. If you want to perform an INSERT then you don't need a WHERE ID= [I]id[/I] because you are inserting something that does not exist. Perhaps you should try an UPDATE | |
Re: The toString() method MUST stay with the same name. In java, the toString() is not a method of String object but of the Object class. And you must override it in your class. ex: when you call: [CODE] Person p = new Person(....); System.out.println(p); [/CODE] Then the system.out, automatically calls … | |
Re: The method Math.random() returns a random [U]double[/U] between 0 and 1. 0 < Math.Random <1; So one variation of jwenting's post : [CODE] private int diceRoll() { double r=Math.Random(); //do stuff return /* An [U]int[/U] number between 1 and 6 */ } [/CODE] | |
Re: [CODE] case 5: z=m5*Quantity; total += z; count++; break; } [COLOR="red"]total += z;[/COLOR] count++; JOptionPane.showMessageDialog(null,"The total Retail Price is "+total,"RESULT", JOptionPane.INFORMATION_MESSAGE); } if(choice==-1){ [COLOR="red"]total +=choice;[/COLOR] count++; JOptionPane.showMessageDialog(null,"The total Retail Price is "+total,"RESULT", JOptionPane.INFORMATION_MESSAGE); } [/CODE] First red: why do you add the total again, when you have already added it … | |
Re: Try something like this: [CODE] double[] getBubbleSort(double[] values) { double [] newArray = new double[values.length]; for (int i=0;i<values.length;i++) { newArray[i] = values[i]; } //your code here return newArray; } [/CODE] | |
Re: I don't if this is correct but what I did once, was to read the file line by line(like you read any other text file). You will get numbers. These numbers represent the RGB values. They are from 0 - 16777216 (256*256*256). | |
Re: Are you using the KeyListener or the ActionListener? If you want the input to be from the keyboard then I wouldn't use JButtons. | |
Re: What I don't understand is that when he says: [QUOTE] (a2+b2+1)/(ab) [/QUOTE] Does he mean: (a*2+b*2+1)/(a*b)? | |
Re: When you press close you have to call the setVisible(true) of the original Menu Window and the setVisible(false) of the add record window. Probably you don't have access to the Menu Window from the add window. Try this In the Menu Window when you call add-window, have it take as … | |
Re: They are different packages with different classes. If you want a class that is inside java.package then import java, or else import javax. | |
Re: First of all no one is going to spend his precious time trying to understand what you are writing in the way you are writing it. Not even you don't use code tags, but also I cannot understand if you are posting two different files (classes) or one, or where … | |
Re: You are declaring total twice: [CODE] double total; //declarations of the neccesary variables int amt; double unitPrice,sum; String product; String ttl; int index=0; double total=0; [/CODE] | |
Re: Try adding a System.out.println(); before the JOptionPane to see where the program stops | |
Re: Inside the: UserListIn.add(GymUser newGymUser) method you will take the new Gym User and compare him with the other gymUsers. If one with the same id already exists then don't add him and print a message or throw an Exception. If you don't want to make this check inside the .add … | |
Re: And when you are receiving an error, that you don't know in a line where you are calling a lot methods one inside another, try to break it a bit: [CODE] String stringToParse = line.substring (line.indexOf(","),line.length()); System.out.println(stringToParse); int num = Integer.parseInt(stringToParse ); blocksArray [numBlocks][1] = num ; [/CODE] In that … | |
Re: I believe that you should write a return statement at the end of your "public static int calcFib (int n)" method. From what I have seen you have return statements in all of your if () { }, but I think that in some versions of the java you need … | |
Re: You cannot move one TextField to another. If you want to change focus, use the focusListeners, and/or the keyListeners. I think there is a method at TextField that sets the focus. If you want to write to a text Field something from another use the getText(), setText() methods. Also check … | |
Re: What exception, where is it thrown, what is the message? And what is your question????? The title of the post is not meant for asking questions | |
Re: What do you mean referencing an array from another class? What are you trying to do? | |
Re: It's seems to me that you already have some ideas. If you don't like them then we cannot know what you would like to do. By the way, what YOU would like to do? Find that out and then [B]Just Do It[/B] | |
Re: I also don't think that this correct: [CODE] public double GreatCircleDistance(lat, lon, alt) { } [/CODE] Shouldn't be : [CODE] public double GreatCircleDistance(double lat,double lon,double alt) { } [/CODE] | |
Re: First of all why create two classes that do the same thing: UserInput1,UserInput2? Just create only one that prints the message: "Give a number" and create two different instances: [CODE] UserInput1 firstNumber = new UserInput1(); int input1 = firstNumber .getUserInput1(); UserInput1 secondNumber = new UserInput1(); int input2 = secondNumber .getUserInput1(); … | |
Re: Didn't I answer that already? [URL="http://www.daniweb.com/forums/post521775.html#post521775"]http://www.daniweb.com/forums/post521775.html#post521775[/URL] | |
Re: Compile it, I think if you are console the command is >javac InputHandler.java (if I remember correctly because for a very long time I have been using IDEs) and run it with the command >java InputHandler Then the program will print the message in your code and then just insert … | |
Re: Assuming that you want to sort an array of numbers then declare your array, read from the input then numbers and store each one of them in the array and then call a method that sorts the array: For reading I use this: [CODE] BufferedReader USERIN = new BufferedReader (new … | |
Re: First of all create a Job object like I told you. Then a method that takes as argument the Jobs (array,vector, or anything else you want with Job objects) and write your code there. Do you know how to sort an array because I think you have to do something … | |
Re: [CODE]byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); }[/CODE] Personally, I don't use very often this kind of way to read files, but why don't you try what masijade has suggested with renaming the file. Do you have access to the … | |
Re: Why don't you post your code, the exception that was thrown and the stack trace. How are we supposed to understand what is the problem? Ask the Oracle from the Matrix:icon_wink: ? | |
Re: [QUOTE]Sorry I am a little confused. Each entry in the java list is in the format: XXXXX,XX/XX/XXXX So if I use String.split(",") it would return an array of Strings as follows: XXXXX,XX/XX/XXXX,XXXXX,XX/XX/XXXX... is this correct?[/QUOTE] If you use split for the XXXXX,XX/XX/XXXX: [CODE] String s="XXXXX,XX/XX/XXXX"; String [] tokens =s.split(","); [/CODE] … | |
Re: No, no, no. The way I see it each Card object must represent a single card the suit, rank must not be arrays. The constructor will take the 2 values and you will pass these values to your class attributes. Both attributes will be Strings. You will have no problem … | |
Re: What do you mean prove it? You DON'T have to prove, it is just the way it is. Do you mean implemented using recursive? | |
Re: Have you set the environment variables? You have to state where the javac command is. Also if you open the command prompt and type java it should print the java version you are using. | |
Re: quarters, dimes, nickels, pennies must be int [CODE] quarters= int(change/25); dimes= int(change/10); nickels= int(change/5); pennies= int(change/1); [/CODE] | |
Re: You cannot run an Applet using main(String [] args) You must use an HTML page. And I think I've seen the same question to another thread, that had the same answer. | |
Re: A good tutorial about html can be found here : [URL="http://www.w3schools.com/"]http://www.w3schools.com/[/URL] | |
Re: Your class must extend the Thread class and implement the run method. (void run()) When your class runs that method it is executed in parallel with any other thread, included the main(String [] args). So just create a class that stores the random numbers in an array. Code must go … | |
Re: The while statement is correct. You don't need the A; it is in the Q where you store your input and that's what you want to modify. If you look your code you will see that you write Q=A/2 without giving any values to A in the first place. You … | |
Re: If C++ is your language then you are at the wrong forum | |
Re: What????? NetBeans released the 6.0? That's amazing. I am still using the 0.0.0.0.1 version:icon_lol: I am going to download it with my PSTN 28kbps connection. By the time it gets downloaded, the 7.0 will be released :icon_lol: | |
Re: When you say that you downloaded them, in what form did you get them? (Perhaps a .jar file) | |
Re: Try something like this: [CODE](int)Math.pow(y,2);[/CODE] or [CODE]System.out.println((int)Math.pow(y,2));[/CODE] if you want to print | |
Re: Try using str.charAt(i) in a for-loop. This method returns one by one each char of the String. Then you can count the different brackets that open and close and make sure that each time the bracket count must be positive or zero. At the end of the loop [U]all[/U] bracket … ![]() | |
Re: Returns true if each "father" can be divided by each of their "sons". false even if one of the fathers cannot be divided by theirs sons. If a node is null, it does not check it and returns true. | |
Re: Finally, this is first time I've seen in this forum someone start a thread with the title:'Need help' and not asking for the solution to his homework without having written any code for himself. | |
Re: You create a double number2 at the beginning of your program, but in the function: button3_actionPerformed you create another Double number2. This is not wrong, but the calculateResult function takes as arguments: 1 String and 2 double. The number2 you are passing is not a double primitive type but a … | |
Re: And you should be thankful that glowkazaf told you how to do it in the first place even though the way you asked for help was rude. If you opened a Java book you would have found out that what you are being asked to do is the simplest thing … | |
Re: Since you don't know the size of the file why don't you put the strings you read into a Vector and then put the data from the Vector to an array ex: String line= readLine() from file vector.add(line) When you are done with the file use a for-loop to put … |
The End.