1,963 Posted Topics
Hi everybody. I have a problem and I need some suggestions. A few weeks ago, my monitor suddenly turned off on its own. Then I shut down my computer and switched it on again, and after 5 minutes the monitor turned off again. This happened several times in a row. … | |
Re: For reading lined from a file: [CODE] try{ BufferedReader loadPlayerPositions = new BufferedReader(new FileReader("/media/KEI-SAMA/CS11/JOKE CS11/KnowGoMilestone5/playerpositions.txt")); String line = loadPlayerPositions.readLine(); while ([B]line!=null[/B]) { System.out.println("Line read: "+line); [B]line = loadPlayerPositions.readLine();[/B] } } catch (Exception e) { System.out.println("Exception: "+e.getMessage()); } [/CODE] With that way you read each line. Do some checking in case … | |
Re: I have been reading your thread for some time now, searched the google, asked my colleagues, called some of my old professors but still no one can answer this important question: [QUOTE=nope3d;1002366] ...Can anybody knows how can I put a table on what type of Package type (overnight and two … | |
Re: Here is an example with arrays: [CODE] Empleoyee emp = new Empleoyee(); // this is an [B]Empleoyee[/B] Empleoyee [] empArray = new Empleoyee[10]; // this an array // emp is an Empleoyee // empArray is an array // the empArray above is not null //empArray[0], empArray[1], empArray[2], ... are [B]Empleoyee[/B] … | |
Re: Can you post the whole stack trace? [QUOTE] java.lang.NullPointerException [/QUOTE] It means that you are trying to use something that is null. At the stack trace you will find somewhere one of your classes mentioned. Go to that line and there something is null | |
Re: Don't write this: [CODE] return (((multi * seed) + incr) % modu); [/CODE] When you calculate the result store it into a variable. Then change the value of the seed with that variable and [U]then[/U] return it. | |
Re: When you write this: [CODE] public void setName(String name) { name = name; } [/CODE] Both "name" in [ICODE]name = name;[/ICODE] refer to the argument. So you are just changing the value of the argument and you are putting the value of the argument back at the argument. If you … | |
Re: Check the class javax.swing.ImageIcon with constructor: [ICODE]ImageIcon(String filename) [/ICODE] Then you can use a JLabel with constructor: [ICODE]JLabel(Icon image)[/ICODE] You might want to consult the above classes' API | |
Re: [CODE] String input = in.next(); if (input.equalsIgnoreCase("Q")) done = true; [/CODE] when you get the input you can do: [CODE] String input = in.next(); // will return the first character // also check the length of input (if input has length 0 you will get an error) char inp = … | |
Re: Without seeing code the only possible and logical way is when you click the button to set the variable that you display as the time back to zero | |
Re: (((10000*5000)-2000*3000)*30/100) / * - * 10000 5000 * 2000 3000 30 100 Is this what you want? | |
Re: First of all this is a question for the JSP forum. Secondly what do you mean when you say "heading". Explain better with some code. Also you can submit the page and when you go at the the next page you can do this: [CODE] <% String uni = request.getParameter("uni"); … | |
Re: Check the [B]Read Me[/B] post at the top of the jsp forum: [U]JSP database connectivity according to Model View Controller (MVC) Model 2[/U] | |
Re: Go to the JSP forum. On top of that there is a link with useful example | |
Re: Can you see something wrong with this code: [CODE] public void setName(String appt){ [B]setName[/B](appt); } [/CODE] You calling the same method. When you call [I]setName[/I] it will call [I]setName[/I] which is inside it, which will call [I]setName[/I] which is inside it, which will call [I]setName[/I] which is inside it, . … | |
Re: By searching this forum you will find plenty of examples on how to read files. Look for the classes: BufferedReader Scanner | |
Re: Get the value. Execute the query. Check the API: java.sql. Connection, Statement, ResultSet Ask specific questions about where are you having problem. | |
Re: [QUOTE=priya ravi;991910]create a program using java for virus can u please help me.[/QUOTE] Does this mean that you want a virus written in java or the opposite? An anti-virus written in java[B]?[/B] | |
Re: Try to put more debug messages: [CODE] System.out.println("Checking rs"); if (rs.next()) { System.out.println("rs.next: TRUE"); int rc = rs.getInt("RecordCount"); System.out.println("rc= "+rc); if ( rc> 0) { isMemberAlive = true; } } else { System.out.println("rs.next: FALSE"); } [/CODE] | |
Re: Semicolon ( [B];[/B] ) separates commands. When you write this: [CODE] if (v1 < 500); total = ((v1 * .02) + 5); [/CODE] You have ONE if statement, that executes [U]nothing[/U] because of the semicolon. It doesn't matter if it returns true or false. It "terminates" at the '[B];[/B]' Then … | |
Re: Use code tags. Click this symbol when you write a post: "#" | |
Re: Your question doesn't make any sense. For calculating sums and totals use a for loop | |
Re: I believe that they are both the same when it comes to the number of Objects created. The difference is the scope of the "MyClass" instance. In the second case you can use the "[I]m[/I]" outside the for-loop. With the first case you cannot. The second case is useful when … | |
Re: I am sorry for being late to respond to this. [B]Firstly[/B] if you read all of the posts related to that particular question in both threads (the poster created 2 threads), you will reach to the conclusion that the [I]poster[/I] was accusing the programming language because he couldn't get his … | |
Re: Then put the reading of the temperature inside the do-while. | |
Re: Is your code working? If not, where are you having problems with? Also I would suggest, next time, to use the javax.swing.* package (JFrame, JButton, ....) | |
Re: This: [CODE] while (myPhrase != null) { myArrayList.add(newPhrase); /****ERROR here*/ } [/CODE] is an endless loop. [I]myPhrase[/I] is not null, you don't change its value inside the loop so it remains not null. Thus the loop will keep running forever and eventually you will run out of memory. I don't … | |
Re: Reading and writing to file using Buffered..... [CODE] BufferedWriter writer = null; try { writer = new BufferedWriter(new FileWriter(file)); writer.write("Line is written to file"); writer.newLine(); } catch (IOException ioe) { System.out.println("Error: "+ioe.getMessage()); } finally { if (writer!=null) writer.close(); } [/CODE] [CODE] BufferedReader reader = null; try { reader = new … | |
Re: You haven't defined the variable: [I]password1[/I] Also you don't need 2 Scanner objects. Use one and call the method [I]nextLine[/I] as many times as you like | |
Re: [CODE] int Monthname = input.nextInt(); int Monthday = input.nextInt(); switch (Monthname) { case 1: Monthname = "January"; Monthday = "31"; [/CODE] Monthday, Monthname are declared as [B]int[/B], at the beginning of your code. But then you do this: [ICODE]Monthname = "January";[/ICODE] "January" is a String. You cannot put a String … | |
Re: You need to give values to your variables: [CODE] int a; int num2; int num1; [/CODE] I suggest you enter put some values inside the code in order to test if the logic is correct: [CODE] int a = 2; int num2; = 4 int num1 = 10; [/CODE] And … | |
Re: Read the API for the method: [I]JOptionPane.showInputDialog[/I] If you test your code and see what happens when the user clicks "Cancel" you will see that the method returns [ICODE]null[/ICODE] as the API says. So you need to do some checking of the "firstname","lastname". | |
Re: [QUOTE=hoke;981773] P.S. I agree that java sucks :)[/QUOTE] Why? Because Someone accidentally misplaced this '=' with this '=='. I am not accusing anyone since I have made such mistakes when copying code, but tell me one language that doesn't use this operator: '=' for assignment. [QUOTE=kahaj]I'm finding it to be … | |
Re: Read input from user. Write if else statements to check what was given and print the appropriate message. Search this forum for example on reading input with the java.util.Scanner class. Check the API of the java.util.Scanner class | |
Re: Use the api of the JCheckBox to get the values and then run an insert query to the database. For better answer ask better and more specific question. | |
Re: I don't know if this will solve the problem, but at this line: [CODE] out.println("<input name='Delete' type='image' src ='images/del.png'value=" + id + " alt='Delete' onclick='javascript<b></b>:return deltest();'/> "); [/CODE] You need a space between the value: [QUOTE] 'images/del.pn[COLOR="Red"][B]g'v[/B][/COLOR]alue [/QUOTE] And here you need to add the single quotes: [QUOTE] out.println("<input name='Delete' … | |
Re: If you check the API, the [ICODE]scan.nextInt()[/ICODE] returns an int value, so it doesn't have a [ICODE]toString()[/ICODE] method. Objects have that method. "int", or "float" and the others are not Objects. Try this: [CODE] myArray[i] = String.valueOf( scan.nextInt() ); [/CODE] | |
Re: [QUOTE=Dajer;978647]Hi friends what's a role of index in RMS? when we use index in RMS? plz I need your help.[/QUOTE] What is RMS then? | |
Re: Your second post is the wrong way to do things. Your first was correct, but you didn't understand the advice given to you. [CODE] for(int i =0;i<ar.size();i++) { Employee emp = ar.get(i); System.out.println(emp.getPosition() + emp.getDepartment() + emp.getName() + emp.getidNumber()); } [/CODE] When you do this: [CODE] for(int i =0;i<ar.size();i++) { … | |
Re: Your post is rather confusing. If I get it right: You will have a list of <select> tags and checkbox tags. Each "select" will be connected with each "checkbox". When the user submits you will have to get the value of ONE "select" box and that select box would be … | |
Re: I would have suggested for the user to give the date format as well. Or perhaps a try-catch with a throw inside the catch in case the user didn't enter a valid date. | |
Re: [QUOTE=akulkarni;966404]check this out [code=JAVA] class searche { public static void main(String args[]) { String s1="tangerine"; int d=s1.length(); int result=0; for(int i=0;i<d;i++) { if(s1.charAt(i)=='e') { result=1; System.out.println("position of e is at "+i); } else result=-1; } System.out.println("result= "+result); } } [/code][/QUOTE] I haven't read the entire thread, but I don't agree … | |
Re: [QUOTE=dasatti;966809]I searched for it on google but no success. Thanks[/QUOTE] Well if it is not on google you will have to write it yourself. If you have any trouble, post your code and you will get help. | |
Re: The only bug I see is you accusing a programming language which has been around for decades, used by thousands, for your incompetence. Just because you can't get it to work doesn't mean it has a bug, it means you don't know what you are doing. It is OK not … | |
Re: [QUOTE=and12;966514]To say that I am not offended at being called "incompetent" in what i thought was supposed to be a friendly forum would be lying. [B]I stated long ago that i was NEWBIE to java. [/B] All i meant by my original post was why not MAJORITY of people can … | |
Re: Run this: [CODE] int N = 4; int M = 3; for (int i=0;i<N;i++) { System.out.print[COLOR="Green"]ln[/COLOR]("I= "+i); for (int j=0;j<M;j++) { System.out.[B]print[/B]("J="+j+" "); } // end inside loop System.out.print[COLOR="Green"]ln[/COLOR](); } // end outside loop [/CODE] | |
Re: Post code and the name of the file. Also you probably need to set the classpath. ![]() | |
Re: A library for formatting dates. Every time I do that I have to create a new SimpleDateFormat, declare the format and use its methods. Have a class that does that. Also you can have a validation method that takes as argument a String and a format and checking if the … |
The End.