1,963 Posted Topics
Re: You are calling the "equals" method and in your class you have created a "eqls" method. Your class need to override the "equals" method: [URL="http://java.sun.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)"]http://java.sun.com/javase/6/docs/api/java/lang/Object.html#equals(java.lang.Object)[/URL] Since you haven't overridden the equals method in your class, in the main, the equals of the super class is called (Object class) that checks … | |
Re: If you run this code you will see that '==' doesn't work: [CODE] public static void main(String [] args) { String s1 = new String("aa"); String s2 = new String("aa"); System.out.println(s1==s2); // false System.out.println(s1.equals(s2)); // true } [/CODE] The '==' checks if they are the same object and the equals … | |
Re: What kind of stored procedure. Do you know how to call that procedure from an sql editor? I would suggest to use PreparedStatements or better: [URL="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/CallableStatement.html"]CallableStatement[/URL]. For more info show what you have done so far. | |
Re: [QUOTE=9944574568;1045038]can u please help me..please send me the code for that how to update the table using stored procedure in jsp program ..need it urgent[/QUOTE] Start a new thread | |
Re: Whenever you do this: [CODE]return new BufferedReader(new InputStreamReader(System.in)).readLine();[/CODE] you keep creating a new BufferedReader every time you call the method. Not very efficient. Try and have the BufferedReader as static and then use it form the static methods. | |
Re: If you are worrying why they are not printed orderly then they are not suppose to. They are threads and they are executed in parallel. So this output shouldn't be wrong: [CODE] 10 8 6 9 4 7 2 5 3 1 [/CODE] | |
Re: What java version are you using? If you are using 1.5 for example then you can map the letters with the morse code using a hashmap: [CODE] HashMap<Character,String> map = HashMap<Character,String>(26); map.put('a', ".-"); map.put('b', "-..."); ... String text = words.getText().toLowerCase(); char[] stringArray = text.toCharArray(); [/CODE] Then you can loop through … | |
Re: If you put it in the session it shouldn't got away. You probably put it in the request, so better show some code. | |
Re: Here is how: 1) Post to correct forum 2) Be more descriptive on your problem 3) Show some effort If you are talking about a web application 4) Learn about request, session 5) Learn about cookies 6) Learn about MVC (find the tutorial at the jsp forum) Do you have … | |
Re: [QUOTE=sitienei;1036000]DUNGEON ADVENTURE [/QUOTE] Thanks for the idea. I have been wanting to create a game similar to this for fun, just to kill time, but couldn't get any smart ideas. I will definitely build this and give it to my friends to play. | |
Re: [QUOTE=firstPerson;1005679]1) Create a array, which represents a table. 2) use a for loop; [code] for(int i = 1; i != 5; i++) myArrayTable[i] = 6*i; //say, myArrayTable is already declared. [/code][/QUOTE] I have a question: Why didn't you use this at the for loop: [CODE] for(int i = 1; i … | |
Re: What is the range of the random numbers? Because you can use the Math.random. Check the API | |
![]() | Re: I can't see a problem with your page. Does the page submits? Does it go from page A to page B? Is the name of the Test.jsp correct and are the pages in the same folder? Does onChange works? Should it be onchange? Also you can try this: [ICODE]document.testForm.submit();[/ICODE] |
Re: At the validation I believe that the seconds should until 59. For the hours you 23, 59. Why not the same for seconds. For the extract when you multiply and then do a mod, you will get 0. 123 * 100 = 12300 12300 mod 100 = 0 12300/100 = … | |
Re: [QUOTE=alsoumhi;1035263]I want to prevent unathorized users to access directly using URL in my application [/QUOTE] When the user logs in, do you put that user in the session? [CODE] String username; String password; // check the database to see if the user is valid. if (yes) { request.getSession().setAttribute("USER",username); } [/CODE] … | |
Re: [QUOTE=masterofpuppets;1034752]hi :) for the first problem you could do something like this: [CODE]public class Mymath { public calculateFactor( int a, int b ) { if ( a < b && b % a == 0 ) return true; elif ( a > b && a % b == 0 ) … | |
Re: Well I would use a double matrix: [CODE] String [][] ARRAY = { {"A", "B", ...}, {"B", "C", ...}, {"C", "D", ...}, .... } [/CODE] Then for mapping the letters with the numbers in a quick way: [CODE] HashMap map = new HashMap(26); map.put("A",0); map.put("B",1); ... [/CODE] The key is … | |
Re: Given your description (the lack of description that is), you may use a System.out.println. | |
Re: First of all when you have questions such as this, always search the API. [URL="http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html#isNew()"]http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html#isNew()[/URL] [URL="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getSession(boolean)"]http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletRequest.html#getSession(boolean)[/URL] From the create session method, you see that it doesn't always create a new session. That call is the same as the no argument getSession() . The only difference is when you enter false. … | |
Re: We don't know what the "Convertor" does. The code seems OK, are you sure the loop doesn't stop? Try printing the data you get from the ResultSet and compare them with what data you have in the database. Also I would suggest to close the Statements: stm, stm1 as well | |
Re: First of all check the Scanner API. You found a code and you didn't think to check the API. Now, there is the nextLine method that reads the next line of the file. Combine it with the has.. methods to read the entire file: [CODE] while (scanner.hasNextLine() ) { String … | |
Re: [QUOTE=shobana_soma;1032930]------------------------------------------------------------------------------------------------MY CODE------------------------------------------------------------------------------------------------------------------------------------------------------- <%@ page import="java.sql.*" %> <%@ page import="java.io.*" %> <html> <head><title>JSP Page</title></head> <body> <% String school = request.getParameter("name"); String name = request.getParameter("username"); String email = request.getParameter("txtEmail"); String pass1 = request.getParameter("pass1"); String pass2 = request.getParameter("pass2"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:shobana", "SYSTEM", "nagalakshmi"); Statement st = con.createStatement(); String sql = ("INSERT INTO register … | |
Re: First of all you don't need to have 2 Scanner classes. One would be enough and you can call its methods as many times as you like in order to read as much input as you want. And to [I][B]VernonDozier[/B][/I], the thread is this: [url]http://www.daniweb.com/forums/thread234373.html[/url] Check posts numbers 16, 17. … | |
Re: At what line you get the error and what does it say and at which class? You probably haven't defined the actionPerformed method. | |
Re: [CODE] public class feetInches { public static void main(String [] args) { int feet = 5; int feetToInches = 12; int inches = feet * feetToInches ; System.out.println(feet + " feet is " + inches); } } [/CODE] If you want the user to enter input then search this forum … | |
Re: Don't loop like this: [CODE] for(int row=0; row<5; row++){ for(int col=0; col<3; col++){ [/CODE] [U]Always[/U] like this: [CODE] for(int row=0; row<array.length; row++){ for(int col=0; col<array[row].length; col++){ [/CODE] | |
Re: Read the comments [CODE] int m [] = { 3, 2, 5, 2 }; int k = 0; // k has value 0 so it returns 3. THEN k is increased because the ++ is after the variable System.out.println("(a)" + m[ k++ ]; // k has now value 1 // … | |
Re: If you search the net with: "ActionListener" you will receive plenty of examples: [URL="http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html"]http://java.sun.com/docs/books/tutorial/uiswing/events/actionlistener.html[/URL] I took an example from that page and modified it to be more simple for you: [CODE] import javax.swing.*; import java.awt.event.*; public class AL extends JFrame implements [B][COLOR="Red"]ActionListener[/COLOR][/B] { JTextField text = new JTextField(20); [B][COLOR="Green"]JButton b … | |
Re: That is done by DHTML. There are examples in the web. Just search using: "html tabs menu" | |
Re: [B]Be more careful!![/B]. You missed the postcode. Count your arguments. | |
Re: I think you need to remove the '0' from the first number: [CODE] personalList[0] = new Personal("Paul "," White ", [B][COLOR="Red"]0[/COLOR][/B]74078L , "51 Princes Street", "North Shields", "Tyne and Wear", 7852384379L); [/CODE] | |
Re: [QUOTE=calcucool;1031162] i need to write a data validation method in which if the user enter a blank name(ex. " "), it prints an error message. if the data entered is valid (ex. "Austin"), it returns the value null. [/QUOTE] You just said the solution: The method will have as argument … | |
Re: First write a method that calculates the n!. Then use a for loop. How many times you will iterate it's up to you. At the for loop you will use the classic algorithm for calculating sums. Declare a sum variable and add to it the result you get from inside … | |
Re: Please post again the code but this time, the code tags end like this: (/CODE) not: (CODE) Also have each class in its own code tags. Use the (code) button when you create a post | |
Re: [QUOTE=Mareshal;1029979]Why you people don't understand? IS JUST A SIMPLE BET WITH MY TEACHER. If I can modify his java text editor somehow, anything, a simple char, I can get a 10 for that lab. Does it mean I cheat if I prove him I can do something he can't?[/QUOTE] You … | |
Re: [QUOTE=nura issa;1030488][QUOTE=Maverick;54326]I am finishing up writing an extensive C/C++ program and am in dire need of completing these 4 short JAVA programs. Any help would be appreciated GREATLY! (I missed a few days of lecture and am extremely behind in this class.. :sad: EDIT: actually just helping me with one … | |
Re: First of all don't do an: [ICODE]ps.executeUpdate()[/ICODE]. You don't update anything to the database, you do a select. So use the method that returns a ResultSet: [CODE] ResultSet rs = ps.executeQuery(); if (rs.next) { // user found } else { // invalid credentials } [/CODE] Don't forget to close the … | |
Re: Don't use these methods: ye.getYear() They are deprecated. Instead use the [URL="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html"]java.util.Calendar[/URL] And use the [U]get[/U] method [CODE] Calendar rightNow = Calendar.getInstance(); rightNow.get(Calendar.MONTH); [/CODE] This will return the month. Read the static fields of the API | |
Re: [QUOTE=system analysis;1029455] A year is a leap year if it is divisible by 4, unless it is also divisible by 100 but not by 400. [/QUOTE] There is your if statement. Use this '%' operator to determine if a number is divisible by another number. It returns what is left … | |
Re: Have 3 methods that accept a: `short []` as argument and return the min, the max, and the average. And next time use code tags. Press the button that says (CODE) when you create a new post | |
Re: The compiler error should be enough to help you fix this. Read it carefully. Focus on the part: "Cannot resolve symbol s1" | |
Re: [QUOTE=Golam Kausher;1027211] I'm having Java course and I have to submit the following programs [B]by the coming Wednesday[/B] [/QUOTE] Was the assignment given to you today? If no, then what were you doing all this time? If yes, then you have a very demanding teacher. [QUOTE=Golam Kausher;1027211] Please may you … | |
Re: Well the assignment is pretty self explanatory. After you read the triangles apply the Pythagorean theorem. [CODE] int a = // read the angle int b = // read the angle int c = // read the angle // if a*a + b*b is equal to c*c then it is … | |
Re: [QUOTE=ankiwalia;1026269] So can anybody please suggest me another method(leaving jsp) to display my data from database on html page[/QUOTE] If you want to display data to html page then you use jsp. Jsp is actually constructed using html tags. So if you don't know html how can you create a … | |
| |
Re: So from what I understood: The reputation system affects both the rep points as well as the voting points of the specific post, [U]but[/U] The voting system affects [U]only[/U] the voting points? Also is it possible when the user clicks the Up,Down button to display a pop up confirmation dialog? … | |
Re: Like I mentioned in this link: [URL="http://www.daniweb.com/forums/thread232042.html"]http://www.daniweb.com/forums/thread232042.html[/URL] The JobTitle method shouldn't be in the Employee class but in the main method |
The End.