1,963 Posted Topics
Re: You need a for-loop inside the while statement. The upper limit of the loop will be the input you give | |
Re: [QUOTE=masijade;709304]Well, 1. That's already been said. 2. The OP has declared the problem solved. 3. You didn't notice that today was declared [inlinecode]today=new date()[/inlinecode] rather than [inlinecode]today=new Date()[/inlinecode].[/QUOTE] And 4. This thread is 15 days old. Try to solve more current threads | |
Re: I have search the java.awt package and didn't find the class Picture: [URL="http://java.sun.com/javase/6/docs/api/java/awt/package-summary.html"]java.awt[/URL] I don't believe that it is a class that the JDK has. Try search it in the internet and you will find plenty Picture classes implemented by others | |
Re: [CODE] while(option!=9) { Name nameBox[]= new Name[500]; } [/CODE] You create a new nameBox every time you repeat the loop, so the first time you are in the loop you give values to the [B]local[/B] nameBox, but when the loop executes again, you create again a new nameBox (new Name[500]) … | |
Re: [QUOTE=peter_budo;707575]If my sleepy mind does play tricks on me, you should do it as [code](File)vector.elementAt(i).getAbsolutePath()[/code][/QUOTE] I think, although it needs to be checked that you should do this: [icode]((File)vector.elementAt(i)).getAbsolutePath()[/icode] Just a suggestion, I don't know if it will work, just try it, because resizing the array is bad idea. Every … | |
Re: Create an object StudentInfo with attributes the name, the grade, and a boolean that indicates if the student has passed or not. Read the file like this: [CODE] BufferedReader reader = new BufferedReader(new FileReader("fileName.txt")) String input = reader.readeLine(); [/CODE] [URL="http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html"]BufferedReader[/URL] The lines of the file will have each one of … | |
Re: I think this: double numberOfMonths = (principal + totalInterest) / ( [U]monthly payments[/U]) Should be: double numberOfMonths = (principal + totalInterest) / ( [U]MonthlyPayments[/U]) And weren't you taught in math class the algorithm? | |
Re: Create a class like this: [CODE] class DataClass { public int intValue; public String strValue; public DataClass() { } } [/CODE] And: [CODE] DataClass arr [] = new DataClass[2]; arr[0] = new DataClass(); arr[0].intValue = 0; arr[0].strValue = "value 0"; arr[1] = new DataClass(); arr[1].intValue = 1; arr[1].strValue = "value … | |
Re: You could compare the bytes you get from reading the file, but I have never used that way and I don't know how it will work. As far as the almost identical you will need to decide the ruling. [URL="http://java.sun.com/javase/6/docs/api/java/io/BufferedInputStream.html"]http://java.sun.com/javase/6/docs/api/java/io/BufferedInputStream.html[/URL] [URL="http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html"]http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html[/URL] [URL="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html"]http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html[/URL] | |
Re: [URL="http://www.andykhan.com/jexcelapi/tutorial.html"]http://www.andykhan.com/jexcelapi/tutorial.html[/URL] This basic tutorial should be enough to understand that the link supplied by [I]masijade[/I] has what you need to start. Guess you didn't bother to give a closer look to the API and search what you need. If you have written code using the API and got stuck somewhere … | |
Re: This is not java. And during your class, have you learned to write classes with main method and run the "Hello World" program? [CODE] class Hello { public static void main(String [] args) { system.out.println(Hello World); } } [/CODE] | |
Re: first of all this: [I]sides = mSides;[/I] should be like this: [I]mSides = sides;[/I] And the error you get is because the method: mRandom.nextInt(mSides) doesn't take as argument a negative or zero number; as the error message says it must be positive. The reason you get the error is because … | |
Re: Java is case sensitive. When you declare an instance like this: Circle radius = new Circle(), this would be wrong: Area = Radius.getArea(). This is correct: Area = radius.getArea() Also you call a method: Circle.setRadius(number) and that method doesn't exist. On top of that if it did exist you should … | |
Re: [QUOTE=stultuske;704099]if you are trying to get (for instance) the total of amount for the customers, just insert your customers in an array and loop over that array getting the amount you want for instance: [code=Java] double total = 0; for( int i = 0; i < customers.length(); i++ ) total … | |
Re: I don't know for sure by try the full path of the image with the extension | |
Re: I assume that the other program (GUI) has a list of classes. Do you know the elements of those classes as well as their methods. If the main GUI page has a constructor you call it with the appropriate data that you get from your program. If the elements of … | |
Re: What the 3 variables of LProp stand for? If they are the 2 bool values and the which method to call then have an if statement checking what is the 3rd input and call appropriately the reight method AND, NOT, ... with the first 2 arguments | |
Re: Can you sent a sample of you java code, because I don't understand what you mean when you say: [QUOTE]My way of coding is more simpler than the public boolean and public void.[/QUOTE] [QUOTE] but in the class file it's everything in the java file but with a symbol. So … | |
Re: Next time be more clear about what is your problem. From what I understood you don't know how to get and use the username from the comboBox? If yes assume that you have a String username variable. For getting the value from a comboBox that has String elements do this: … | |
Re: The name of the file must be the same as the name of the class and as the name of the constructor. That is why in java terminology we don't say 'file' but 'class' Is the name of the file: EmployeeSystem ? Then this : [CODE] public class EmployeeDirectorySystem { … | |
Re: [QUOTE=chicago1985;701683]I have a Form input field in my JSP:[code] <input name="nickname" type="text" value="<%= NameClass.getInfo() %>" /> [/code] How do I make sure this data is escaped correctly to be able to show quotes and apostrophes. I tried slash in front [b](name=\"nickname\")[/b] and it didnt work. I dont have JSF,Struts, JSTL, … | |
Re: [CODE] mport java.util.Scanner; public class ClockDemo { public static void main (String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter the Current time Hours: "); int currHours = keyboard.nextInt(); System.out.println("Enter the Current time Minutes: "); int currMin = keyboard.nextInt(); TimeAT current = new TimeAT(currHours, currMin); } [/CODE] The same way … | |
Re: Write a Clock class which uses TimeAT class objects to store the current time and an alarm time. The Clock class should have 3 constructors: - A no-arg constructor - A constructor which takes one TimeAT object as an argument and sets the current time - A constructor which takes … | |
Re: If you have provided with java code, we could help, even if the code was wrong. But if you have written it in another language, what do expect us to do? Write the entire application just to tell you that: Yes, it works in java! | |
Re: First of all the assignment is very wrong. The idea is to learn OOP. As other have understood your teacher should have said to create an object Student with the elements required and have an array of Students. The way your code is written I would suggest all of your … | |
Re: [CODE] int i=0; switch (i) { case 1: System.out.println("Value 1"); break; case 2: System.out.println("Value 2"); break; } [/CODE] The code checks 'i''s value. When it finds a case that has that value, it executes what is under it. So the above code will print: "Value 1". Then break will be … | |
Re: Actually [I]adiel224[/I] even forgot to close the bracket :D This will not compile: [CODE] public void update(....){ //complete here ..... [/CODE] This will: [CODE] public void update(....){ //complete here //..... } [/CODE] And that is the only help you will get after such post | |
Re: Are you allowed to use these classes provided by java: java.util.Vector java.util.ArrayList ? If yes then things are much easier | |
Re: First of all static methods are called this way: BankAccount.setName(accountName) I hope that your methods are not static. Second with this code, you create 2 new instances, when you need 1. You will need to have 1 instance and modify its values. [CODE] for(i = 1; i < totalAccounts; i++) … | |
Re: The second window will have a conwstructor that will take as argument the first window: public Frame2 (Frame1 f1) The Frame1 (first window) will have variables that will take value from the second window when you click 'Add'. When you click 'Add' from the second window you will give values … | |
Re: If there isn't, why don't you create one, and post it on the Internet for others to take it. Isn't this what you are asking from the others? | |
Re: The concept of stack is not unique in java. It applies not only in the programming world but everywhere, so I will explain the basic concept. When you put items in a stack you place each one of them after the other. But when you try to take these items … | |
Re: Try posting part of the code, and try putting a System.out.println() in the mouseclicked event before you call the function. Personally I prefer actionEvents for just clicking | |
Re: The problem is in the evaluatePostfix method, as the error says. Probably because the program goes to else if { ... } and you try to do a int op1 = stack.pop() If the stack is empty how can you pop something from it? First check if the stack has … | |
Re: >cboStart.addItem(new Integer(1)); >boStart.addItem(new Integer(2)); // and so one to 12 >cboStart.addItem(1); >cboStart.addItem(2); // and so one to 12 > > >Use any of these two methods. > >Regards, >PuneetK The: cboStart.addItem(new Integer(1)) will add Integer objects to the ComboBox and you will have to cast them to Integer when you … | |
Re: By the way, I don't agree with the way the ParserException is written. This is not the right way to extend the Exception class | |
Re: If you don't know java why are you starting with gui when you don't know even the basics of the language? Start by writing simple console programs and learn how to use classes, extending them . . . | |
Re: As the error says you have probably forgot to put somewhere a ")" And if you can't debug something that simple or you don't know how to pass arguments, what are you doing writing that complex code (for you skills)? How many programs that are executed from console have you … | |
Re: Here is an example for your problem followed by a link from this forum: Static: [CODE] class Test { public static printMyName() { System.out.println("My name IS NEO"); } public static void main(String [] args) { printMyName(); //or Test.printMyName(); //both will work } } [/CODE] Non Static: [CODE] class Test { … | |
Re: Where are you having problems. For reading command line I use something like this: [CODE] BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter set of values:") String input = keyboard.readLine(); [/CODE] If you enter: 3 4 Then the String input will have this value: "3 4" So you can do something … | |
I presume that by back button you are referring to a browser and you have implemented that with JSPs. In that case when the username and password are correct, save the username in the session before you redirect to the next page. Then when you go to the next page … | |
Re: Where do you get the errors? (at which lines) Post part of the code where you get the error, with the error message | |
Re: Since you created it dynamically using java, then you can the values that you displayed and write a method that take these values and store them in the database. If the values, are user inputs then use the <form> tag and submit the form to another jsp, take the values … | |
Re: Use the BufferedReader class with stultuske's code. This class contains the readLine() method you need | |
Re: Aren't you going to tell us where is the error? And probably you are using a method that doesn't exist | |
Re: These methods and variables don't need an instance of the object to be used: If in an object: MyObject there is the static variable: VAR and the static method method1(), then instead of: [CODE] MyObject my=new MyObject(); String s = my.VAR; my.method1(); [/CODE] you can also do this: [CODE] String … | |
Re: JSPs have nothing to do swing. (That was my first mistake). Meaning that you cannot modify your code to convert swing to JSP. The only thing you can keep the same are the classes. Everything that is GUI related has to go. Which is why we don't implement too much … | |
Re: [QUOTE=Alex Edwards;682679]When will you ever say yes, or turn off your email blocking??? When will the madness stop??? =P[/QUOTE] Madness? This is SPARTA. PS: And I am from Greece | |
Re: In the class: ClassRecord have you implemented (overridden) the method toString() ? If not then when you call this: [CODE] pw.println(theList.toString());; [/CODE] since you have no toString() method you call the toString() method of the super class. Yes, ClassRecord has a super class, the Object class. In final what you … |
The End.