Forum: Java 2 Days Ago |
| Replies: 2 Views: 181 You need to have an upper limit for the channels. Declare it as a constant in the TVRemote class.
When you try to increase the channel above that limit then have channel become 1. When you try to... |
Forum: Java 10 Days Ago |
| Replies: 9 Views: 386 The error is pretty obvious and has nothing to do with sql:
You are calling a method that throws an exception, and you don't catch it.
I mean why did you surround the... |
Forum: Java 12 Days Ago |
| Replies: 15 Views: 684 As masijade said post what you have done so far and we will see what we can do for you. |
Forum: Java 22 Days Ago |
| Replies: 4 Views: 338 for (int i = 0; i < adj2.length; i++) {
for (int j = 0; j < adj2.length; j++) {
path += adj[i][j]*adj[j][i];
}
}
The above always returns 0. If you run the code by hand you will see... |
Forum: Java 24 Days Ago |
| Replies: 16 Views: 711 I agree. I prefer to write my own gui.
Surely I also use a Gui Builder but just to quickly declare and place the elements.
But most of the times I do them on my own.
It is hard to use a gui... |
Forum: Java 24 Days Ago |
| Replies: 2 Views: 511 You haven't described what is your problem and what have you done so far. Don't expect us to read the entire code and see what works and what doesn't.
Also you are mixing everything up.
Forget... |
Forum: Java 26 Days Ago |
| Replies: 2 Views: 413 Use a for loop, to loop through the ArrayList and print its elements instead of the System.out.println(row1) |
Forum: Java 28 Days Ago |
| Replies: 8 Views: 459 I ran this:
Music [] array = new Music[3]; // array is an array and it is not null
// Its elements are so you need to initalize them
array[0] = new RockSong();
... |
Forum: Java 29 Days Ago |
| Replies: 8 Views: 459 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 29 Days Ago |
| Replies: 8 Views: 459 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 30 Days Ago |
| Replies: 5 Views: 387 I don't really get the above, but I have a few corrections to add.
First, don't use the toString method of the exception. Use the getMessage to print the error.
String output2 = "Incorrect... |
Forum: Java 31 Days Ago |
| Replies: 5 Views: 418 The split returns an array. And you try to cast it to ArrayList.
From the String get the String [] array using the split method.
Then loop through the array and add its elements to an ArrayList |
Forum: Java 31 Days Ago |
| Replies: 5 Views: 399 I think you should keep your code they way it was and return the index where the target element was found. Without increasing it by 1. In your methods you should always return indexes the way they... |
Forum: Java 33 Days Ago |
| Replies: 4 Views: 320 You can make the method static. Like the main. |
Forum: Java 33 Days Ago |
| Replies: 4 Views: 320 As the error says, You cannot call a non-static method inside a static method. |
Forum: Java Nov 19th, 2009 |
| Replies: 3 Views: 293 Check the API.
p.addActionListener(new gameinit());
The JFrame class doesn't have such method: addActionListener.
Then search the API some more to find which elements accept an ActionListener... |
Forum: Java Nov 19th, 2009 |
| Replies: 3 Views: 293 In order for this method to execute:
public void actionPerformed(ActionEvent e)
{
Izzy.hittable();
Izzy.movement();
if(rar == 'T')
{
System.out.print("Sky High(Grand... |
Forum: Java Nov 19th, 2009 |
| Replies: 5 Views: 399 Well since you found the number you know one of the occurrences of the number.
Assume this:
You are looking for '3'
And you find the position of the "Red" 3. So all the others 3s will be either... |
Forum: Java Nov 17th, 2009 |
| Replies: 2 Views: 381 You can check the API to see if there is a way to get the data from the table. |
Forum: Java Nov 17th, 2009 |
| Replies: 7 Views: 349 This thread has already been solved and you added no additional information.
Also using eclipse will not solve the problem but it will make it bigger because the user will not have learned a thing... |
Forum: Java Nov 16th, 2009 |
| Replies: 7 Views: 517 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 Nov 16th, 2009 |
| Replies: 4 Views: 299 I don't know. Have you checked the API for Treemap? |
Forum: Java Nov 16th, 2009 |
| Replies: 7 Views: 349 Try run it without the .class extension:
> java Hi
Then post the error that you will get :) |
Forum: Java Nov 16th, 2009 |
| Replies: 16 Views: 1,046 You need to use java.util.Date, not java.sql.Date. |
Forum: Java Nov 16th, 2009 |
| Replies: 7 Views: 517 Yes, but you didn't say what the error is. The code seems fine. What is your problem?
Also you should post a few lines of the file you are reading.
Also check the API for the class: Scanner:... |
Forum: Java Nov 15th, 2009 |
| Replies: 14 Views: 574 I would suggest, before asking such questions, first to check the java API:
java API (http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html)
javax.swing... |
Forum: Java Nov 15th, 2009 |
| Replies: 14 Views: 574 You don't need the newPatron object. In the if statements you will only have one instance. You will not have an instance of the super class. Only of child classes. The way you have it in the if... |
Forum: Java Nov 14th, 2009 |
| Replies: 16 Views: 1,046 Isn't this suppose to throw an ArrayIndexOutOfBounds Exception?:
names[names.length] = ...
names's length is 1
java.lang.ArrayIndexOutOfBoundsException: 1 |
Forum: Java Nov 14th, 2009 |
| Replies: 14 Views: 574 Inside the actionPerformed you can try this:
private void actionPerformed(ActionEvent event) {
// assuming that you have a list globally of type Patron (the super class)
if (radioButton1... |
Forum: Java Nov 13th, 2009 |
| Replies: 4 Views: 310 The phone[][] is null. That is why you are getting the exception.
And no this:
String phone[][] = { {"A", "B","C"},
{"D", "E", "F"},
{"G","H", "I"},
{"J", "K", "L"},
... |
Forum: Java Nov 13th, 2009 |
| Replies: 14 Views: 574 I didn't quite realize your problem but here are some suggestions.
You can have one class with all the info and you can have one field indicating what type it is. You can have if-statements that... |
Forum: Java Nov 13th, 2009 |
| Replies: 4 Views: 310 |
Forum: Java Nov 13th, 2009 |
| Replies: 14 Views: 574 I am not familiar with the classes of the javax.swing you are using but my experience tells me this:
Firstly, I assume that the method you use to add the book to the list takes as argument an... |
Forum: Java Nov 12th, 2009 |
| Replies: 14 Views: 574 Because this:
123456789123
is not an int, it's a long.
It is a classic mistake when you try to use a big number. If you check the API you will see how big an int can be.
What value does this... |
Forum: Java Nov 12th, 2009 |
| Replies: 14 Views: 574 These lines are incorrect:
GetBookDetails();
newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN);
with the GetBookDetails you get all the date from... |
Forum: Java Nov 12th, 2009 |
| Replies: 4 Views: 259 If you run this code you will see that '==' doesn't work:
public static void main(String [] args) {
String s1 = new String("aa");
String s2 = new String("aa");
... |
Forum: Java Nov 3rd, 2009 |
| Replies: 2 Views: 184 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 Oct 31st, 2009 |
| Replies: 21 Views: 731 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 Oct 31st, 2009 |
| Replies: 21 Views: 731 Vector vIf = new Vector();
....
// inside the while loop
if (line.equals("if")) {
Freq[1] = Freq[1] + 1;
vIf.add(lineCount);
} |
Forum: Java Oct 31st, 2009 |
| Replies: 19 Views: 594 You know very well that this is not the way to declare variables:
int firstnumber = 1,2,3,4,5,6,7,8,9,10,11,12,13;
int secondnumber = 1,2,3,4;
If you can't fix this, don't go any further.
... |