1,963 Posted Topics
Re: You don't need the StringTokenizer: [CODE] BufferedReader br = new BufferedReader(fr); int numOfVowels = 0; String line = br.readLine(); while (line!=null) { char [] ch = line.toCharArray(); // loop the char array. // for each character in the array, if you find a vowel increase the numOfVowels // always the … | |
Re: First of all learn how to read data from the database and proper OOP. When you copy code you must understand what it does. Not use it blindly: [CODE] while(res.next()){ count ++; } res.beforeFirst(); .. [/CODE] Where in your code you use the 'count' variable and what is its purpose? … | |
Re: Have you looked at the printStackTrace ? | |
Re: Did you put that at the url: httt//:localhost:8085//webapp//jsp//index.jsp ? Because it needs to be: httt//:localhost:8085/webapp/jsp/index.jsp Provided that the index.jsp file is at the right location. | |
![]() | Re: Write a for loop from 1 to 36000. Check the Random class and use the method return a random number twicwe in the loop. Once for the fist die and second for the second die. |
Re: The error is pretty clear: [QUOTE] Cannot invoke compareToIgnoreCase(int) on the primitive type int [/QUOTE] String is an object, so it has methods that you can call, like: compareToIgnoreCase. But ints, as well as doubles, ... , are primitive types and don't have methods to call. Why don't you use … | |
Re: Learn to use code tags. click the CODE button, when making a post. Always do this: double[] array = new double[201]; for (int i = 0; **i < array.length**; i++){ when you print the array values, do you get what you wanted? Is the total sum correct? The code looks … | |
Re: Line 25: [ICODE]System.out.println(object5.mName());[/ICODE], I doubt that the Month class has a method mName() . What errors do you get and what are you trying to do? | |
Re: [QUOTE] java.lang.NullPointerException at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source) at javax.swing.plaf.basic.BasicListUI.getCellBounds(Unknown Source) at javax.swing.JList.getCellBounds(Unknown Source) at javax.swing.JList.ensureIndexIsVisible(Unknown Source) at sun.swing.FilePane.ensureIndexIsVisible(Unknown Source) at sun.swing.FilePane.doDirectoryChanged(Unknown Source) at sun.swing.FilePane.propertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source) at java.awt.Component.firePropertyChange(Unknown Source) at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source) at javax.swing.JFileChooser.setSelectedFile(Unknown Source) [B]at GalleryPanelTest.testGalleryPanel(GalleryPanelTest.java:35)[/B] [/QUOTE] At line 35 of the file: … | |
Re: What do you do when you login? Do you put the username into the session? | |
Re: You need to add an actionListener to the button, so when it is clicked a method would be called. Look at the API for the Button and for ActionListener. Also try to use the swing package: javax.swing.* And the classes: JFrame, JButton, .... Also it is good to read some … | |
Re: The rs is of type ResultSet, the "" is type String. Why do you think that this : [ICODE]rs.equals("")[/ICODE] will work, since you are comparing a ResultSet object with a String object. If the query returns no data, then the first call to the rs.next() will return false. Also it … | |
Re: Have you written any code? Look at your requirements: -Load the data into from a file into an array of address book So create an AddressBook class. Personaly I don't like the name of the class given by the assignent, because an AddressBook has many entries, but assume fot the … | |
Re: Not to mention that you didn't even need to pass it as parameter because you already had it: [CODE] class ArrayGet { [B]int[] a = new int[20];[/B] .. } [/CODE] In the same way you call the Display() with no arguments and it takes the correct global array a[], the … | |
Re: You are missing something basic in Java which is why you should leave JSP and practice more: [CODE] if (myvar.equals("compareme")) out.println("string matches"); else out.println("string MISMATCH"); [/CODE] | |
Re: If you don't know that the first method is the constructor and that it creates an array of bytes, then there is no point in continuing explaining when all you need to do is some studying on your own. The code does what it does. It has for-loops, while-loops and … | |
Re: When A.jsp first loads the V is null. So you can do this: [CODE] <% String V = request.getParamater("V"); if (V==null) { %> <form onsubmit="return validateSelect()"action="Select.jsp" method="get"> <h2>Select:</h2> <h3>Enter the URL of the publisher you perfer to publish your ads on: </h3> <br/> <input type="text" name="SUrl" style="width: 250px;" /> <input … | |
Re: count1 is non static. It is an attribute of the MergeSort1 class and must be called the way the non static methods are called: [CODE] MergeSort1 marr = new MergeSort1(maxSize); System.out.println("Number of comparisons: " + marr.count1 ); [/CODE] When you are inside the class MergeSort1 you are ok, because it … | |
Re: [QUOTE=masijade;1197405]Your method is returning a single double, rather than a double array, and you index into an array, not a double.[/QUOTE] Look at [I]masijade[/I]'s post. And you made the same mistake to another of your posts. | |
Re: I would suggest to remove the final and make it private. Then add a public method that returns its value. [CODE] private static String EXIT=ButtonConstant.getString("BUTTON_CONTENT"); public static String getEXIT() { return EXIT; } [/CODE] With that way the value changes, but no one can change it programmatically If this doesn't … | |
Re: [QUOTE=ubi_ct83;1197385]yup. i got it!! 1) To get d item from dorpdown menu: String tvalue_str=(String)t2.getSelectedItem(); 2) this is d way i write to display the selected item : int3.append("Value of T ="+tvalue_str+"\n"); thanks sennat_26[/QUOTE] I would like to add that in the same way you added String to the JComboBox, you … | |
Re: I don't know anything about jsf, but can you make it so it won't be session scope? If you had already thought of that, then sorry, but that's all I can think of. | |
Re: You need to set the appender of the logger: log4j.properties file: [CODE] log4j.logger.log_name=debug, F log4j.appender.F=org.apache.log4j.DailyRollingFileAppender log4j.appender.F.File=full_file_path/file.log log4j.appender.F.DatePattern='.'yyyy-MM-dd [/CODE] Every day the old file will be renamed according to the pattern, Look at the API for the class: org.apache.log4j.DailyRollingFileAppender and for the Logger class. | |
Re: First of all study some html. The "select" tag misses the "option" tag which is the one that has the "value" attribute. If you look at the tag, you don't give it any value. So of course it displays null since you don't send anything. [URL="http://www.w3schools.com/default.asp"]http://www.w3schools.com/default.asp[/URL] Second don't just call … | |
Re: First of all the this.pig is null. You declare it as attribute at the class but you never give it value. You need to pass the parameter of the constructor to it: [CODE] public Amplifier(Pig aPig) { this.pig = aPig; this.number.resetCount = 0; } [/CODE] Also in the reset method … | |
Re: I haven't looked at the code but only this part: [CODE] pictures = reader.nextInt(); ... title1 = reader.nextLine(); [/CODE] This is why I never use the nextInt methods and I prefer this: [CODE] pictures = Integer.parseInt(reader.nextLine()); ... title1 = reader.nextLine(); [/CODE] So here is what happens because it has been … | |
Re: I can't understand the second question. For the first: [CODE] Date date = new Date(); // or Calendar cal = Calendar.getInstance(); [/CODE] Look at their APIs. [URL="http://java.sun.com/j2se/1.5.0/docs/api/java/util/package-summary.html"]http://java.sun.com/j2se/1.5.0/docs/api/java/util/package-summary.html[/URL] | |
Re: Each class must the other as global attribute. When a button is clicked call setVisible(false) method of the one you want to hide and setvisible(true) of the one you want to show. The above methods are methods of the JFrame class. You can also have the constructors so they can … | |
Re: If you look at the API of the Vector class you will see that there is a method that lets you add an element at a specific place. I think it is like this: [CODE] add(int i, Object obj); [/CODE] Look at it, but if I remember correctly, it adds … | |
Re: Use a while loop: [CODE] while (true) { .... } [/CODE] Keep reading input from the keyboard. When, for example, you enter "quit", exit from the loop using the "break" command. Else convert that input into a number and add it to the list. [CODE] String input; while (true) { … | |
Re: what errors do you get after running the code? The toString method seems fine. If it doesn't work, then maybe the problem is in the way you put data at the queArray and the way you define the front, rear | |
Re: In the main you create 2 instances of the class: TicTacToeGame. Shouldn't you be creating TicTacToeplayer instances? | |
Re: You need to post the line that you get the error. The error messages, indicates the line that it happened as well as the file. | |
Re: Print the query that you are executing: [CODE] String query = "....."; [COLOR="Green"]System.out.println(query);[/COLOR] i1=st1.executeUpdate(query); [COLOR="Green"]System.out.println(i1);[/COLOR] [/CODE] What does it print? Also try to take the query that was printed and run it to an sql command promt. | |
Re: Post your whole code. And this: [B]<%=employeeIDArray[i]%>[/B] suppose to be put in the "html" code. Not in the scriplet | |
Re: What kind of data, you want to save and do you have any "homework" restrictions concerning how the data will be saved? There is the easy way using the Serializable interface. The code is only a few lines, but you will not learn much. And the hard way would be … | |
Re: Is is against the forum rules to spam; and any other forum. When you have nothing useful to add or post new information dont post at all. [I]ProgrammersTalk[/I]'s post which was quoted in [I]peter_budo[/I]'s reply was such: [QUOTE] that's just the same thing haha.. [/QUOTE] What did it contribute to … | |
Re: Inside the overridden method use code that checks the color. If it is purple, don't change it | |
Re: Look at the API of the Scanner class. Use the methods hasNextInt and nextInt. Read the numbers and use a for-loop for each line, in the while loop. The numbers will tell you how many asterisk you will print. Also read the assignment for that matter. Surely you know how … | |
Re: Assuming that you are using java 1.5 or later then: [CODE] public class SomeObject implements Comparable<SomeObject> { public boolean equals(Object obj) { if (obj==null) return false; if (obj instanceof SomeObject) { SomeObject so = (SomeObject)obj; // write your code here that compares the values of the so attributes with the … | |
Re: You need to provise more information. How was the jar file created, how do you run it, and do you get any error messages? | |
Re: Since you start the index from 0 the first loop would be this: [CODE] for (int i = 0; i < sides; i++) [/CODE] If sides = 3, then i = 0,1,2. 3 sides. Or: [CODE] for (int i = 1; i <= sides; i++) [/CODE] If sides = 3, … | |
Re: In this thread you ask the same question: [URL="http://www.daniweb.com/forums/thread274702.html"]http://www.daniweb.com/forums/thread274702.html[/URL] An answer has been given to your question. Don't go around making new threads with the same question. NO one is going to write the code for you no matter how many thread you start. You have been given suggestions; now … | |
Re: Actually you need to convert String to int. If this: [B]emarks_txt[/B] is a JTextFiled then this: [ICODE]emarks_txt.getText()[/ICODE] returns String. But your Enrollment constructor takes as argument an int: Enrollment(String student_id,String subject_code,String Grade, [B]int [/B][B]Marks[/B]) So you can do this: [CODE] int Marks = Integer.parseInt(emarks_txt.getText()); Enrollment e = new Enrollment(eid_txt.getText(),ecode_txt.getText(),egrade_txt.getText() , … | |
Re: First of all don't use the list() method because it doesn't return the full path and you forced to do this: String NewDir = dirLocation +"\\"+filename; Try this: public void method(File dir) { File [] children = dir.listFiles(); for (int i=0;i<children.length;i++) { if (children[i].isFile()) { BufferedReader reader = null; try … | |
Re: Call all the methods in the main like you are doing and after each call, print the instance. This: [ICODE]System.out.println (x);[/ICODE] will not work because: When you call the System.out.println with an object as argument, the toString method of that object is called. Since you haven't defined such method, the … | |
Re: Have you tried reading the errors that you get? Because If you had the solution would be very easy: [QUOTE] Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at Transfer.actionPerformed(Transfer.java:111) [/QUOTE] You get a NullPointerException at the Transfer.java file, at the actionPerformed method at line 111. You are using something which is null. … |
The End.