1,963 Posted Topics
Re: [QUOTE=luwenbin;855876] [QUOTE=ithelp] Ok, after coding it I will send it to your professor directly , let me know his email address. [/QUOTE] SNIP I don't believe he fell for that! | |
Re: Something else that came to mind: Use the split method like this: [ICODE]String[] str = stringRead.split(" ");[/ICODE] This will get you all the 'words' including the ":". So loop throught the array until you find the ":". You will know that, what is before the ":" and after should be … | |
Re: Instead of PrintWriter use: BufferedWriter. When you write to the file, it overrides what it is written: [CODE] FileWriter fileWriter = new FileWriter("fileName"); //better check the API for this BufferedWriter writer = new BufferedWriter(fileWriter); writer.write("line"); writer.newLine(); // or writer.write("line\n"); writer.close(); // again check the API because I don't remember if … | |
Re: [QUOTE=get2tk;852451] The following class might be useful: java.util.Date represents dates. Its toString() method returns the date and time in human readable form: getTime() returns a long representing the date in milliseconds, so that (d1.getTime() - d2.getTime())/1000L will be the time in seconds between dates d1 and d2. Finally, new Date() … | |
Just a quick question. No rush to answer, it is not important, I might discover it later myself, but just in case someone knows it: I have been trying to create a [URL="http://java.sun.com/javase/6/docs/api/java/lang/reflect/Method.html"]Method[/URL] object using this method: [URL="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#getMethod(java.lang.String,%20java.lang.Class...)"]Class.getMethod(String name, Class<?>... parameterTypes)[/URL] like this: [CODE] obj.getClass().getMethod(methodName, Class.forName(methodType)) [/CODE] My problem is … | |
Re: First of all this: [ICODE]if (buffer.equals(null))[/ICODE] is totaly wrong. Not because it won't compile but because [B][U]If[/U][/B] buffer is null you cannot call any methods. You will get a NullPointerException The best way to check if something is null is the simplest: [ICODE]if (buffer==null)[/ICODE] For all the other cases use … | |
Re: [QUOTE=Waqas_Moeed;853083] Try this one.... Regards .................[/QUOTE] Congratualtions, The oldest thread reviving I have ever seen. Not to mention all the forum rules that you've just broken. (We do not give away free homework and we use code tags) Last post by [I]server_crash[/I] was [B]May 8th, 2005 14:16[/B]. What were you … | |
Re: [QUOTE=Zass101;849612]I will pay the first person to finish this task via paypal!!! I will pay $5! [/QUOTE] Only $5 !! You have to be insane. Firstly, the amount in insulting. In this forum there are many professional programmers that get paid much much more. Why should they bother to fix … | |
Re: [QUOTE=BestJewSinceJC;846678]Yes, read it in as a String and print it out. ?[/QUOTE] Actually what [I]smsamrc[/I] is asking is to print at the console something like this: To have 2 as base and 3 to be smaller and to the upper right corner of 2. | |
Re: Search for code examples on how to read files (Scanner, BufferedReader). Write some test classes that just print the data of the files Search for code examples on how to run queries. Write some test classes that execute simple. Use the above to read the data, construct the queries and … | |
Re: The problem is where you create your query not where you read the value and call the set method: Assuming this: [CODE] public void setId(String id) { this.id = id; } [/CODE] >>> query = . . . . + "[COLOR="Red"][B]'[/B][/COLOR]" + id +"[COLOR="Red"][B]'[/B][/COLOR], " I think you forgot to … | |
Re: Pass the information from one frame to the other before you call the "show" method. Remember you can have the TextFields of the second frame public or with set methods in order to set their values from the first frame | |
Re: [CODE] String [] array = new String[5]; // array is not null but array[0], ... are null //array variable is an array and should be treated like one. // instatiating the elements of the array: array[0] = "aa"; array[1] = "bb"; System.out.println("Array: "+array); for (int i=0;i<array.length;i++) { System.out.println("Elements: "+array[i]); } … | |
Re: I didn't quite understood what you really want because I think it is very simple: [CODE] Vector v = new Vector(); v.add("4 2 5 3 6 0"); [/CODE] or [CODE] Vector v = new Vector(); v.add("4,2"); v.add("5,3"); v.add("6,0"); [/CODE] or insert them in any format you like | |
Re: I think using javascript. I don't have time to look it up but if you search at [URL="http://www.w3schools.com/default.asp"]w3schools[/URL], you will find a complete reference of DHTML in order to do what you want | |
Re: The first error is easy. You cannot compare String using this: "<". For Strings you need to use this function: [CODE] if ( txt_pay.getItem().compareTo(txt_amount.getItem())<0 ) { jOptionPane1.showMessageDialog(this, "please enter the right amount"); } [/CODE] And when you do this: [CODE] if (txt_pay.getItem().isEmpty()) [/CODE] The method isEmpty() needs to return a … | |
Re: A small tutorial with examples about objects in arrays [CODE] Video video = new Video(); // ONE instance of Video Video [] videos = new Video[5]; // this is an array // videos is an array and should be treated as an array // videos[0] is a Video but it … | |
Re: [QUOTE=chriswellings;839536]really? do you like it (both code geass and anime in general?) how many other series have you seen?[/QUOTE] I have noticed this thread about anime and since I am also a fan I would like to answer that I have seen in total about 95 anime. Starting form Astroboy … | |
Re: The error is simple, it cannot find the cinstructor you are using: "cannot find symbol constructor Plane (int,int,int,int,int,int,java.awt.Image, java.applet.AudioClip, Player)" Meaning that the constructor you are using doesn't exist. I haven't looked at your code, but the arguments you enter at the constructor must much the ones that are declared … | |
Re: We already know what factorials are and how to compute them. But thanks anyway for the tip | |
Re: Where exactly do you get those exceptions. A FileNotFoundException means exactly that; the file you are trying to access doesn't exist. | |
Re: >Create variables to hold how many times each value occured: [CODE] int countOf2s = 0; int countOf3s = 0; ... [/CODE] >Create a method that returns a random number from 1 to 6 > inside a for loop (it will be executed 12000) call the above methods 2 times, add … | |
Re: Your input method seems correct but there are a few things you need to add: [CODE] public static void Input(String [] composer, String [] piece) { int i = 0; while( i<composer.length ) { String comp = JOptionPane.showInputDialog("input composer"); if (comp.equals("q")) { break; } else { composer [i] = comp; … | |
Re: I don't know if this suggestion applies to your problem, but you can try this: Have the class implement the [URL="http://java.sun.com/javase/6/docs/api/java/lang/Comparable.html"]Comparable[/URL] interface: [CODE] public class ContactListLabel implements Comparable<ContactListLabel > { public int compareTo(ContactListLabel label) { return nameLabel.compareTo(label.getNameLabel()); } } [/CODE] When you get the Contacts from RMS and store them … | |
Re: [QUOTE=loren_28;740056]kindly please help to solve my problem??? create a program that the user allow to input a 5 integers, that looking the lowest value?[/QUOTE] It would be useful to read a Thread before posting to it. Perhaps your question has already been answered. | |
Re: The setText method does exactly what it says; it SETs the text of the TextArea. So The TextArea will have whatever value you put as argument. You can either, create a String with all the values and then set that String OR BETTER: Use the append method of the TextArea. … | |
Re: You can have the variable be "global". Here are 2 examples: [CODE] class ClassA { public int variableA = 0; public ClassA() { } public void method() { variableA = 2; } } [/CODE] [CODE] class ClassB { public ClassB() { } public void methodB() { ClassA clA = new … | |
Re: Obviously instead of 3 you will have the number of '*' you want to print. And in the for-loop use the method: [CODE] System.out.print(""); [/CODE] The above method doesn't change line. Of course when the loop is done remember to call the one that changes line in order to continue … | |
Re: Even if you do come up with an algorithm for that you will still need to make some comparison.So why don't you try this: [CODE] public int max(int a, int b, int c) { if ((a>=b)&&(a>=c)) { return a; } if ((b>=a)&&(b>=c)) { return b; } return c; } [/CODE] … | |
Re: You might want to create your own class. The classes Date and Time are used to store what the say: Date and Time. You need to store duration. (duration of race) You cannot say that a swimmer swimmed for 'Date' object time. But you can say this:He started swimming at … | |
Re: [CODE] <form name="theForm" method="post" action=""> [/CODE] Where it says action you need to put the jsp which you want to go after submiting the form. If it is let empty, it is submitted to the same form. So try this: [CODE] <form name="theForm" method="post" action="anotherPage.jsp"> [/CODE] You can also put … | |
Re: I also like to do small projects just for fun. Especially projects that I can use for my self. Although I don't find this project very interesting here is what you can do: > In one package write the classes as explained in the diagram. > In another package, classes … | |
Re: You can loop backwards the arrays, take the elements and convert them into Strings and concatenate them. Then convert the Strings to numbers and multiply them. [CODE] String s; loop i take element i convert it to String concatenate it to s variable end loop convert s to number [/CODE] | |
Re: That does it do, and what it was supposed to do? Also tell us where is the problematic part of the code. Also you might want to add some [I]System.out.println[/I] and see what are the values of the variables at the parts you are having problems | |
Re: That is not a consructor: [CODE] public void myDataModel(Adult[] memAd ) { // pass in data array to constructor data = memAd; } [/CODE] This is a constructor: [CODE] public MyTableModel(Adult[] memAd ) { // pass in data array to constructor data = memAd; } [/CODE] I see that at … | |
Re: Simple program to read ONE file: [CODE] BufferedReader reader = new BufferedReader(new FileReader("filename.txt")); String line = reader.readLine(); while (line!=null) { // line read is not null // do things with the line ... .. . // read the next line and go to the beginning of the while. If it … | |
Re: Java GUI is just another class. You can create instances of other classes inside and call their methods. Small, silly example: [CODE] class Person { public String name; public int age; public Person() { } } [/CODE] [CODE] class Print { private Person person; public Print(Person p) { person = … | |
Re: add2 method is void. So it doesn't return anything. It just adds the argument to the Money object calling it. When you call it, as you can see, it adds the argument to the dollars and cents of the object that made the call. Also your minus algorithm is wrong … | |
Re: [QUOTE=ejosiah;833030]@stephen84s posting links with little relevance to any of us[/QUOTE] Sorry to intrude, but what do you mean by that? | |
Re: I know the algorithm for pong. But my brother is better, he knows Ping Pong. Serioulsy, he learned it when he was at University and now he teaches gymnastics at schools | |
Re: Try this simple example: [CODE] String s = "asjdhk123uhmsmik,z!?"; for (int i=0;i<s.length();i++) { char ch = s.charAt(i); System.out.println(ch); } [/CODE] Also you should always check the API to find more methods that could be useful. In this case, you should have looked the [URL="http://java.sun.com/javase/6/docs/api/java/lang/String.html"]String API[/URL] | |
Re: x cannot be integer: [CODE]<input type="text" name="1">[/CODE] [CODE] String value = request.getParameter("1"); [/CODE] "1" is a String Now if you want the VALUE to be taken as an integer: [CODE]<input type="text" name="textName" value="123">[/CODE] [CODE] String value = request.getParameter("textName"); int intValue = Integer.parseInt(value); [/CODE] At the last example, the textfield can … | |
Re: [CODE] <td> <a href="MyFacility.jsp">Test Three Forward</a> </td> [/CODE] | |
Re: [URL="http://www.daniweb.com/forums/thread141776.html"]http://www.daniweb.com/forums/thread141776.html[/URL] It is at the top of the jsp forum | |
Re: [ICODE]System.currentTimeMillis();[/ICODE] It returns the current time in milliseconds. So you can call this method before the java method you want to count and then call it again and get the difference | |
Re: There is a link at the top of this forum. How can you miss it? [URL="http://www.daniweb.com/forums/thread141776.html"]http://www.daniweb.com/forums/thread141776.html[/URL] | |
Re: [QUOTE=stultuske;822272]I think he's trying to get a servlet running, not sure though[/QUOTE] Or a simple GUI. [I]damu[/I], you need to better describe your question and what you are trying to accomplish. An example would help | |
Re: I haven't used FileChooser much, but have you tried these methods: [QUOTE]setApproveButtonText(String approveButtonText) Sets the text used in the ApproveButton in the FileChooserUI. [/QUOTE] [QUOTE] showDialog(Component parent, String approveButtonText) Pops a custom file chooser dialog with a custom approve button. [/QUOTE] | |
Re: [CODE] BufferedReader reader = null; try { reader = new BufferedReader(new FileReader("fileName")); String line = reader.readLine(); while (line!=null) { System.out.println("The Line is: "+line); // do calculations with line line = reader.readLine(); } } catch (Exception e) { } finally { if (reader!=null) reader.close(); } [/CODE] If you are unfamiliar with … |
The End.