Forum: Java 4 Days Ago |
| Replies: 8 Views: 256 After taking a closer look at the code you don't need the casting. Since you read from the file a Music object, it doesn't matter what type of music it is:
while (true) {
Music music =... |
Forum: Java 4 Days Ago |
| Replies: 8 Views: 256 Even though from your code you have figured out on your own how to use array of objects here is a small example:
Music [] array = new Music[3]; // array is an array and it is not null
// Its... |
Forum: Java 9 Days Ago |
| Replies: 4 Views: 216 You can make the method static. Like the main. |
Forum: Java 10 Days Ago |
| Replies: 7 Views: 246 After searching for examples on the net, I found this:
Assuming your file is like this:
And you run this:
RandomAccessFile raf = new RandomAccessFile("fileName","rw");
... |
Forum: Java 10 Days Ago |
| Replies: 7 Views: 246 I think that the RandomAccessFile (http://java.sun.com/j2se/1.5.0/docs/api/java/io/RandomAccessFile.html) might help you. |
Forum: Java 12 Days Ago |
| Replies: 1 Views: 155 I would have used the sleep method:
// line read:
line = readLine();
// take the time at the end of the line:
lone time = ... ;
try {
Thread.sleep(time); |
Forum: Java 13 Days Ago |
| Replies: 7 Views: 307 Because you only have ONE tempPerson object. You have the same instance of it:
tempPerson.setPerson(tempName, tempAddress, tempBirthDate);
System.out.println(tempPerson.getLastName()); //... |
Forum: Java 13 Days Ago |
| Replies: 4 Views: 202 It will work, but don't forget that each element of the iterator will have one of these:
java.util.Map.Entry (http://java.sun.com/j2se/1.4.2/docs/api/java/util/Map.Entry.html) |
Forum: Java 13 Days Ago |
| Replies: 7 Views: 262 Try run it without the .class extension:
> java Hi
Then post the error that you will get :) |
Forum: Java 13 Days Ago |
| Replies: 16 Views: 582 You need to use java.util.Date, not java.sql.Date. |
Forum: Java 17 Days Ago |
| Replies: 3 Views: 209 You aren't making any sense |
Forum: Java 26 Days Ago |
| Replies: 2 Views: 164 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 *... |
Forum: Java 26 Days Ago |
| Replies: 4 Views: 253 Your first code will not compile and it is not java (elif)
The second is totally inefficient and shows no thinking at all to the real problem |
Forum: Java 29 Days Ago |
| Replies: 21 Views: 641 Actually I understood that the objective was to monitor how many times a word appeared.
I would suggest sth like this:
String word;
Vector linesAppeared;
And the size of the vector would be... |
Forum: Java 34 Days Ago |
| Replies: 4 Views: 248 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.
Does this mean that next time you will do it on your... |
Forum: Java Oct 23rd, 2009 |
| Replies: 19 Views: 1,131 I haven't look at your code but from your explanation, I assume that you create the second frame, when the button is clicked?
If yes declare the second frame as global variable and create it once.... |
Forum: Java Oct 23rd, 2009 |
| Replies: 6 Views: 267 public static float average(short [] grades) {
// calculate the average using a for loop
}
And to call it after you have your array created and entered values in it:
short [] grades =... |
Forum: Java Oct 17th, 2009 |
| Replies: 6 Views: 314 I don't think it's possible. Whenever you type something it is stored in the variable, therefor you need an if statement, but I would suggest to wait for other people responses as well in case... |
Forum: Java Oct 16th, 2009 |
| Replies: 3 Views: 316 Sorry for my double post but when you are done with your solution, there is a much smarter - but more difficult - way you can try:
String [] words = {"Alpha", "Bravo", ....};
Now when you get... |
Forum: Java Oct 13th, 2009 |
| Replies: 2 Views: 160 Providing private lessons is not what we do here. Check the Read Me thread with the tutorials on top of this forum, and we will answer specific questions about any errors you might get with your code |
Forum: Java Oct 12th, 2009 |
| Replies: 1 Views: 491 In case you haven't noticed we have October. Tanning is out of the question, unless you plan to use the application at the South hemisphere. |
Forum: Java Oct 8th, 2009 |
| Replies: 1 Views: 200 Usually a NullPointerException means that you are trying to use something that is null. So if you get the exception at line 63:
_file.pixels[x][iy].setValue("b");
it would mean that:... |
Forum: Java Oct 7th, 2009 |
| Replies: 19 Views: 1,131 From what I see you use a lot of "extending" that I don't think is necessary. Your code works but it could have been simpler.
First don't use the "dispose" method.
Second you need to close the... |
Forum: Java Oct 6th, 2009 |
| Replies: 4 Views: 297 I think he wants a javax.swing.* program.
What you ask is impossible because we don't know your requirements. We cannot just start writing a program that does nothing using random commands with no... |
Forum: Java Oct 6th, 2009 |
| Replies: 2 Views: 275 I believe that your problem is this:
String s1 = new String( secondLength );
....
lastName.getChars ( 0, 5, secondLength, 0 );
When you create the "s1" the "secondLength" array is empty.... |
Forum: Java Oct 2nd, 2009 |
| Replies: 9 Views: 305 for (int l = 0; l < info.length; l++){
info[l] = loadPlayerPositions.readLine();
info[0] = Players.nameOfPlayer1.toString();
info[1] =... |
Forum: Java Sep 25th, 2009 |
| Replies: 6 Views: 330 Can you see something wrong with this code:
public void setName(String appt){
setName(appt);
}
You calling the same method. When you call setName it will call setName which is... |
Forum: Java Sep 4th, 2009 |
| Replies: 6 Views: 491 I don't know if it is possible to get the "My Computer" as root, but check this out:
File [] files = File.listRoots();
for (int i=0;i<files.length;i++) {
... |
Forum: Java Sep 3rd, 2009 |
| Replies: 7 Views: 392 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... |
Forum: Java Sep 2nd, 2009 |
| Replies: 11 Views: 295 Yes, we are good at it
What does this suppose to mean? Have you any idea what you are asking. It's not enough that you cheated at your assignment, you have the nerve to tell us that you cheated... |
Forum: Java Aug 20th, 2009 |
| Replies: 4 Views: 328 I get it now.
I was sent a PM from chingkoysilog (the OP) asking to give him the solution of an assignment that involved salespersons and calculating some total values per products and ... |
Forum: Java Aug 2nd, 2009 |
| Replies: 2 Views: 469 First of all I find it surprising that you wrote this code and still couldn't find the answer.
I mean was it so difficult to add this to your code?
if (lineNo==5134)
{
line = br.readLine();... |
Forum: Java Jul 27th, 2009 |
| Replies: 9 Views: 744 Classes begin with capital. Methods with lower.
StringConcatenate stringConcatenate1 = new StringConcatenate();
stringConcatenate1.stringConcat();
You create an object/instance of type... |
Forum: Java Jun 15th, 2009 |
| Replies: 8 Views: 365 No you shouldn't use unicode for declaring methods and variables.
You use unicode for unsupported characters. If your keyboard has the 'a' then use it for the name of your method. What's the point... |
Forum: Java Jun 12th, 2009 |
| Replies: 2 Views: 202 From what I understood, first you delete and then you insert, when you want to do an Update.
Well you can try and run an Update query. When you "SELECT" data from the database you use a userID as... |
Forum: Java Jun 9th, 2009 |
| Replies: 7 Views: 1,036 Do you have somewhere another class named Random? |
Forum: Java Jun 8th, 2009 |
| Replies: 6 Views: 396 You will find no servants here that are obligated to answer to your questions. If you didn't get a reply it was probably because people didn't know the answer or they were busy with their own... |
Forum: Java Jun 4th, 2009 |
| Replies: 4 Views: 250 The answer is simple English grammar:
A method throws an Exception:
public void method(int i) throws Exception {
}
The method throws an Exception when you call it |
Forum: Java May 20th, 2009 |
| Replies: 4 Views: 611 setModel (http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JTable.html#setModel(javax.swing.table.TableModel))
Also check the
TableModel... |
Forum: Java Apr 27th, 2009 |
| Replies: 5 Views: 710 Well this is what I got with mixed numbers:
It should have returned '3'.
After searching the API for collections (http://java.sun.com/javase/6/docs/api/java/util/Collections.html)
found that... |