- Upvotes Received
- 7
- Posts with Upvotes
- 7
- Upvoting Members
- 7
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
54 Posted Topics
Re: A couple of notes: 1. I see no problem with [CODE] public void add(Object o){ array[this.position] = o; this.position++; } [/CODE] 2. The if-statement in your second add() method is wrong 3. You should do some check on the index in several of the methods 4. indexOf()/lastIndexOf() shouldn't return 0 … | |
Re: [CODE] String s = "C:\\Documents and Settings\\user\\My Documents\\"; System.out.println("Before: " + s); s = s.replace("\\", "/"); System.out.println("After: " + s); [/CODE] Note the usage of [B]replace[/B], not replaceAll. | |
Re: Well, it's not strange that you only get the last item since each call to getItems() will loop through the whole list and end up with the last element each time. Depending on the layout of your program (didn't read all of your source code, only the getItems() method) you … | |
Re: Do you have a particular problem or do you just want someone to code it for you? If the latter, you're not going to get that kind of help here. Please post specific problems and show that you have tried to solve them on your own. | |
Re: Short answer, No. Unfortunately it's a b**ch to print stylized text to the terminal/command prompt in Java. If you really need it, take the time to learn some of the libraries out there. | |
Re: [QUOTE=Daigan;1686242]When I used InvalidCharException it says it wasn't found, does that mean that the Ready to Program Java IDE doesn't have that exception?[/QUOTE] You either have to create your own InvalidCharException or just throw a regular Exception. The Exception class is sort of the super-class to all other exceptions, totally … | |
Re: You've got a couple of errors. 1. When the string is of length 3 you assign a variable "third" a value but this value is never returned. 2. Your if-else statements are wrong @ lines 40-42 (maybe somewhere else too) [CODE] if(input.substring(0,2).equals("10")) first = "Ten of "; else if(input.substring(2,3).equals("D")) third … | |
Re: I would definitely say go ahead. I did a similar project in a CS course a couple of years ago, combining Java and MySQL. There are a number of different libraries for Java when it comes to MySQL, but if you want to keep it simple and not mix in … | |
Re: I dont know that dbconn.commit() returns but if it returns something that can be interpreted as a success or failure, lets say true/false for the sake of argument. Then you could do something like [CODE] if (!dbconn.commit()){ dbconn.rollback(); <- will still be inside try/catch } [/CODE] if not you need … | |
Re: You need to call addPennies() etc. to actually add the money to the piggybank,. | |
Re: What do you mean it's not displaying correctly? I guess your output would look something like studentNameAssignmentNameScoreGrade because that is how you call it from line 34. If you would like to tidy it up do something like [CODE] Grader grade1 = new Grader(lastName, assignment, grade, letterGrade); System.out.println("Student: " + … | |
Re: Good luck getting help with that. Describe your problem, post the code related to it and use the code tags. | |
Re: Start by using the CODE tags when posting code and only post the code that is related to your problem, not the whole program. If people need to see more code they will ask for it. No one is going to read through that thing you just posted. | |
Re: I'd suggest a recursive method, something like [CODE] public int sumPower(int n, int m) { return (m > 0) ? (int)Math.pow(n, m) + sumPower(n, m-1) : 1; } [/CODE] Edit: Just saw there was a recursive method proposed already. Oh well, they differ a little bit I guess. | |
Re: As stated by a few other posters above I'd go with MySQL as well for this. It is fairly straightforward and you dont have to develop a whole server application that has to be very careful with it's resources (probably reading/writing the highscores to a file). Two clients trying to … | |
Re: [URL="http://java.sun.com/developer/technicalArticles/tools/webapps_1/"]http://java.sun.com/developer/technicalArticles/tools/webapps_1/[/URL] is a good start. When you are done with that follow the links on the bottom of the page. It is a bit of a hassle to get started with, but if I remember correctly there are a few vids on youtube explaining how to write a Hello World … | |
Re: [QUOTE=SMITA6076;1526498]So I just need to do the [ICODE]calendar.add( Calendar.DATE, 14 )[/ICODE] before the return statement rather than in it?[/QUOTE] It was just the wrong return type. You tried to return calendar.add(...) which isn't a String. Check [url]http://download.oracle.com/javase/1.5.0/docs/api/java/util/Calendar.html#add(int[/url], int) | |
Re: I've not looked through the PDF but under each case X: you simply replace the code in there by a method call i.e [CODE] ... case 1: feetToInch(); break; ... [/CODE] and then you declare your feetToInch() method (note that it has to be static in your case) [CODE]private/protected/public static … | |
Re: Have you got a specific precision you want to achieve? Otherwise just put it in a for-loop like [CODE] double tSeries = 0.0; for(int i = 3; i < SOME_NBR_TO_ENSURE_PRECISION; i += 2){ if(add){ tSeries += Math.pow(r,i) / factorial(i); } else { tSeries -= Math.pow(r,i) / factorial(i); } }[/CODE] Wont … | |
Re: On a side note, you will have some problems with your linearSearch() as it has void as a return type. Change it to int and you'll be fine :) | |
Re: Also, don't think there's anything like a "simple java speech recognition program". That kind of software is pretty advanced. | |
Re: What do you have to start with? Are you only looking to represent the position of an object in two dimensions? Is time a factor here? Usually to represent what you are describing one uses spherical coordinates, and there are formulas to convert from cartesian (x,y,z) to spherical coordinates. [url]http://en.wikipedia.org/wiki/Cylindrical_coordinates#Spherical_coordinates[/url] | |
Re: Line 25: collection[i] is a MusicAlbum object that you are trying to assign a String (br.readLine() returns a String). You need to convert the String into a MusicAlbum object. Line 77/79: Same thing here. You have temp1 set as a Album[] while collection is a MusicAlbum[]. Also, you might want … | |
Re: Can you give an example string that generates a OOM Exception? | |
![]() | |
Re: Your eliminateDuplicates method is not even close to solving the problem. You need to compare 2 numbers in the array and if they are the same, you discard one. Create a temporary array that you can fill up with the unique values and then return this array when you are … | |
![]() | Re: You're gonna have to have a separate thread to keep track of the seconds. Keep in mind that the sleep(long t) doesn't guarantee to sleep exactly t ms so you're going to have to do some error checking here to remove "drift" efftects. |
Re: Your constructor is supposed to take two arguments. On line 5 you are not supplying any arguments. Besides that most of your code is also wrong. | |
Re: You missed the first post in the forum? [url]http://www.daniweb.com/forums/thread99132.html[/url] | |
Re: You have an int called payroll (declared on line 12) that you try to invoke methods on. | |
Re: You need to change your code a little bit. The Scanner class is very inconsistent when it comes to handling tokens. If you read a line using nextLine() and then read a primitive type such as an integer/double/float/whatever the omitted newline character from the previous call will cause trouble. So … | |
Re: If you are new to Java, this project is probably way out of your league if you don't have massive experience in other programming languages and can learn Java really quick. And by the way, why do you need to configure the router to keep track of the remaining time? … | |
Re: Looks like school assignments so I wont explicitly tell you the answers, you need to figure it out on your own. 1. In the getMaxX() method you need to iterate over all the Points and compare each x-coordinate. Have a local variable to keep track of the largest x-coordinate and … | |
Re: You need to initialize the object with the keyword [B]new[/B], like [CODE]Object o = new Object();[/CODE] Or in your case you need to initialize the Inventory object. All declared and not explicitly initialized objects are initialized to null, hence the NullPointerException | |
Re: You are calling methods on an object inside the other methods that they do not know about. Remove myAtm before each method call and it should work. Note: the notation you are using is for calling methods on an object from "the outside", like in the main method you could … | |
Re: I copy-pasted your code and it works fine for me within the desired ranges. However you do realize that you have to enter a house number twice even if its right the first time? Why not use a regular while loop? | |
Re: You are never going to get that kind of help here. Post specific parts of your code that doesn't work and describe what you have done so far. | |
Re: Cant see anything wrong with that code. Illegal start of expression usually comes up when you try to declare a method inside another method or you have open/close brackets in places they shouldnt be. Check for those things first and get with more code (and use the CODE tags. | |
Re: Please... it took me 2 seconds to find it using Google. [url]http://www.jfugue.org/[/url] - you'll find examples and the whole JavaDoc here. | |
Re: You only call chosenItem() once. If you add [CODE]chosenItem(selection, foodTotal);[/CODE] in the end of chooseYourItem() it should work. It's not very nice but if you dont want to work with loops just yet it should do the trick. | |
Re: When you say web services do you mean real web services or are you talking about network programming with Java? Because the way you described what you want to do you could accomplish with network programming. | |
Re: Depends on which mobile platform you are developing for. But as far as Java goes you could either go with JavaME (Mobile Edition) or Android if that's a possibility for you. | |
Re: What have you done so far and what problems have you encountered? | |
Re: First off you are not saving any of the CyberBooks you create in the method addBook(). You need a data structure to keep track of the added books, otherwise the findBookTitle() will be impossible to implement. There is also a few lines of code in there that I dont really … | |
Re: [QUOTE]What ideally would be happening here is that instead of entering 30 at once, once the first value is entered, it would break back to the switch and case, and then the next time that case 1 was entered it would do the same except enter to arrayIn[1] instead of … | |
Re: Maybe he's asking about the difference between a java application and java applet? | |
Re: [QUOTE]Is there any chance of making my list prettier, i.e. without the [] around my list?[/QUOTE] Just change the printC() method to print it in the way that you want it. To get access to the Strings in eat you could either use the traditional for-loop like: [CODE] for(int i … | |
Re: If you are working with File objects the delete() method should work for empty folders. Edit: Missed that you used FTPClient, however the method deleteDirectory() should work on directories as well. Are you catching any exceptions when trying to delete? Have you double checked the path? Edit2: You are calling … | |
Re: Im sorry, this is off topic but does anyone else think that the requirements are kind of odd? A university asks the students to solve, a rather large problem, in only the main method. And also, they are not allowed to use arrays but can use hashsets. Why would they … | |
Re: The method itself looks alright, and as you say it works some of the time. How does the code calling send() look? The problem might be in there. Or the problem could even be in the inputstream that handles then sent message. |
The End.