1,963 Posted Topics

Member Avatar for StarZ

You don't add friends here: [CODE] System.out.println("Enter a friend by their first name"); firstName = input.nextLine(); [B][COLOR="Red"]friendList.add(firstName); [/COLOR][/B] System.out.println("Enter a friend by their last name: "); lastName = input.nextLine(); [B][COLOR="Red"]friendList.add(lastName); [/COLOR][/B] System.out.println("Enter their telephone number: "); telephone = input.nextLine(); [B][COLOR="Red"]telephoneList.add(telephone);[/COLOR][/B] [/CODE] You simply add the info of one friend. How …

Member Avatar for javaAddict
0
1K
Member Avatar for leoeroy

Are you sure you have the right formula? Also shouldn't you have this: [CODE] powerSeries [B][COLOR="Green"]+=[/COLOR][/B] 1 +(negationFactor * (Math.pow(radians, expFact))/factorialResult); [/CODE]

Member Avatar for leoeroy
0
2K
Member Avatar for lacompsr

I started this post after you added your second post. The extended class seems fine. What is the problem with driver. Just instantiate it and call its methods.

Member Avatar for lacompsr
0
617
Member Avatar for sheehab

Edit: Sorry for the mistake post. I didn't see the names of the posters. Also, [I]sheehab[/I] posting just the code will not do you any good. You need to explain what it does in general, what it is supposed to do, how it behaves now, what errors do you get …

Member Avatar for javaAddict
0
162
Member Avatar for justM
Member Avatar for theCommander

If you want to use a .txt file, and you find databases difficult find examples on how to read files in this forum using the Scanner class or the BufferedReader class. After you read the file into a Vector or ArrayList check the username and password entered to see if …

Member Avatar for theCommander
0
168
Member Avatar for nitrogen33

First of all, don't do this: [CODE] for (int i = 0; i < 20; i++) ... for(int i=0; i <12; i++) [/CODE] Use the length of the array: [CODE] for (int i = 0; i < tran.length; i++) ... for(int i=0; i <inter.length; i++) [/CODE] How do you know …

Member Avatar for javaAddict
-2
54
Member Avatar for eechan03
Member Avatar for jakal121

Try a for loop, start would be one of the numbers and the end the other. Check to see which one is greater in case you need to display them in descending order, by reducing the index instead of increasing.

Member Avatar for javaAddict
0
106
Member Avatar for lightner86

Use the String.[B][COLOR="Green"]charAt()[/COLOR][/B] method to loop and get each character. Then have a HashMap. Whenever you get a character check the map. If it is in there then take the value stored, increase it by one and then put it in the map to replace the old value. If it …

Member Avatar for javaAddict
0
76
Member Avatar for Web_Sailor

I don't believe that getClickCount does what you think it does. Nor if you get the Point, you will be able to find which button was clicked. If all you want is to disable the button then: [CODE] buttons[i].addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { JRadioButton source = (JRadioButton)e.getSource(); …

Member Avatar for javaAddict
0
134
Member Avatar for StarZ

If you search this forum you will find examples on how to: > Read a file > Write to a file > Use the split method > Create objects > Add them to Vector or ArrayList And to make things simpler, don't try to put everything in the main method. …

Member Avatar for P00dle
-3
107
Member Avatar for tootaa

Actually you should have something like this: [CODE] int index = 0; for (int i=0;i<array.length;i++) { int num; // read int number System.out.[B][COLOR="Green"]print[/COLOR][/B](num+" "); // loop again through the array to see if that number already exists if (doesn't exists) { // put it into the array [B][COLOR="Red"]array[index] = num; …

Member Avatar for mrnutty
0
954
Member Avatar for P00dle

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 [U]add[/U] its elements to an ArrayList

Member Avatar for P00dle
0
638
Member Avatar for theStruggler

Well since you found the number you know one of the occurrences of the number. Assume this: You are looking for '3' [QUOTE] 1 2 3 [B][COLOR="Red"]3[/COLOR][/B] 3 4 5 [/QUOTE] And you find the position of the "Red" 3. So all the others 3s will be either left or …

Member Avatar for theStruggler
0
115
Member Avatar for cute.sridhar

[QUOTE=cute.sridhar;1051959]There is any java Language Translation API. If so means, please indicate that API.[/QUOTE] Please explain.

Member Avatar for cute.sridhar
0
90
Member Avatar for bobinson

If I understood correctly whenever you click a button you need to get a value from a "set of values" depending on the value of the radio button? If yes then you don't need any listeners to the radio buttons. Whenever a button is clicked, you can get the value …

Member Avatar for Ezzaral
0
88
Member Avatar for jeniferandrews

The problem is probably because it cannot find this class: com.microsoft.jdbc.sqlserver.SQLServerDriver when you call the Class.forName Have you download and set to your classpath this driver: [ICODE]com.microsoft.jdbc.sqlserver.SQLServerDriver[/ICODE]?

Member Avatar for jeniferandrews
0
323
Member Avatar for GTJava

[QUOTE=GTJava;1053446] ERROR: non-static method isPrime(int) cannot be referenced from a static context [/QUOTE] As the error says, You cannot call a non-static method inside a static method.

Member Avatar for GTJava
0
151
Member Avatar for clem998

For starters, use the .equals method to compare the equality of Strings and any other objects. See what happens and I will look closely the rest of code later. [CODE] String s1 = "a"; String s2 = "b"; // examples boolean b = s1.equals(s2); b = s1.equals("ccc"); b = "abc".equals(s2); …

Member Avatar for javaAddict
0
99
Member Avatar for gunjannigam

One suggestion is to read the entire file and then write again what you want at the first line and the write the rest of the data read

Member Avatar for javaAddict
0
104
Member Avatar for MxDev

[QUOTE=MxDev;1052174]Sorry I couldn't get it, would you make it a little bit clearer!!!!!!!! Thanks [EL-Prince][/QUOTE] What? Wasn't this clear enough? [QUOTE=Ezzaral;1051862]Learn manners first.[/QUOTE] Who are you to demand?

Member Avatar for MxDev
-3
166
Member Avatar for vasunttfshimoga
Member Avatar for saadismail85

for-loop that adds spaces equal to the number of row currently printing. Also use for loop to display the number of "*" Displays N spaces [CODE] for (int i=0;i<N;i++) { System.out.print(" "); } [/CODE]

Member Avatar for javaAddict
0
98
Member Avatar for Rajashree24

I would suggest to look for tutorials on all of them. In sort: > Statement for executing "raw" queries: [CODE] String name = "Name A"; String query = "select * from table_A where name = [B][COLOR="Green"]'[/COLOR][/B]" + name + "[B][COLOR="Green"]'[/COLOR][/B]"; // Use statement to execute the above query. [/CODE] > …

Member Avatar for javaAddict
0
79
Member Avatar for gunjannigam

The dashed borders appear whenever you select something. If you add a lot of buttons in a frame and you click one it is natural the it will appear selected. I believe that these dashed line are to show you which element you selected. My advice, although you will have …

Member Avatar for javaAddict
0
102
Member Avatar for CuteCat

In order for this method to execute: [CODE] public void actionPerformed(ActionEvent e) { Izzy.hittable(); Izzy.movement(); if(rar == 'T') { System.out.print("Sky High(Grand Nuave)"); } } [/CODE] You need to add its listener to a component. The methods in the 'KeyListen' are executed because you do this: [CODE] p.addKeyListener(new KeyListen()); [/CODE] When …

Member Avatar for javaAddict
0
202
Member Avatar for brandon84

Aren't you suppose to do this: [CODE] dRetirement = keyboard.nextDouble(); [B][COLOR="Green"]dGrossPay = [/COLOR][/B]grossPay(dHours, dRate); //netPay(dGrossPay, dRetirement); [/CODE] Instead of this? [CODE] dRetirement = keyboard.nextDouble(); grossPay(dHours, dRate); //netPay(dGrossPay, dRetirement); [/CODE]

Member Avatar for brandon84
0
126
Member Avatar for Trogan

You already have a for-loop, you don't need another while-loop. Max should be initialized with one element from the array, preferably the first so you can start your loop from i=1: [CODE] max=arr[0]; for (i=1;i<arr.lenth;i++) { } [/CODE] When you write: int max=0,i; you declare i to be an int, …

Member Avatar for Ezzaral
1
982
Member Avatar for Ryujin89

Your problem is reading the file. What is the format of the file. Can you post some of its data. Also I would suggest to create an object with properties the data you are reading: [CODE] class YourClass { private String employeeName=null; private int employeeNum=0; .... // declare constructor and …

Member Avatar for Ryujin89
0
307
Member Avatar for wild_angel
Member Avatar for wild_angel
0
110
Member Avatar for 00musdan

Try to better explain your problem. What you posted is difficult to quite understand. Also, don't tell me that your teacher hasn't showed how to write a single class with attributes and get/set methods. Or don't you have a book or notes with examples?

Member Avatar for 00musdan
0
163
Member Avatar for littleladyclair

I suppose by the time you have been given this assignment your teacher has showed you how to write programs and how to run them or how to declare methods ans use them. I assume that you have some notes on how to declare and instantiate classes, or how to …

Member Avatar for javaAddict
0
547
Member Avatar for gunjannigam

I would have used the sleep method: [CODE] // line read: line = readLine(); // take the time at the end of the line: lone time = ... ; try { Thread.sleep(time); } catch (Exception e) { } // repeat the loop [/CODE] I would suggest to put the above …

Member Avatar for javaAddict
0
86
Member Avatar for hallwayantics

Try run it without the .class extension: > java Hi Then post the error that you will get :)

Member Avatar for Makoto1981
0
192
Member Avatar for cwarn23

Isn't this suppose to throw an ArrayIndexOutOfBounds Exception?: [CODE] names[names.length] = ... [/CODE] names's length is [B][COLOR="Red"]1[/COLOR][/B] [ICODE]java.lang.ArrayIndexOutOfBoundsException: [B][COLOR="Red"]1[/COLOR][/B][/ICODE]

Member Avatar for cwarn23
1
353
Member Avatar for SteveTheRed

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: [URL="http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html"]http://java.sun.com/j2se/1.5.0/docs/api/overview-summary.html[/URL] You will find it at the link: java.util at the left …

Member Avatar for SteveTheRed
0
1K
Member Avatar for GiRL,IT
Member Avatar for Web_Sailor

When you get that error it means that something is null. At that line it means that 'fc' is null. Did you initialize it? Because I didn't see it in your code.

Member Avatar for Web_Sailor
0
135
Member Avatar for heroherohero

It's not a big challenge. We can easily do it. Can you post something more difficult because I am bored?

Member Avatar for javaAddict
0
33
Member Avatar for saadismail85

You should have made this a code snippet. Nevertheless it is very simple example, very useful only for beginners.

Member Avatar for saadismail85
0
102
Member Avatar for P00dle
Member Avatar for Ne00m

[CODE] Partysupply[] pippo = new Partysupply [20]; pippo[0] = new Partysupply(); [/CODE] You need to initialize all the elements of the array. With your code, you initialize the pippo[0] [U]but[/U] the pippo[1], pippo[2], pippo[3] are null. Don't forget that when you do this: [ICODE]pippo = new Partysupply [20];[/ICODE] You initialize …

Member Avatar for javaAddict
0
174
Member Avatar for pochis40

And are we suppose to do? From what I read you didn't ask any questions in your post.

Member Avatar for javaAddict
0
67
Member Avatar for ag1021

Check out the css tutorial at: [URL="http://www.w3schools.com/css/default.asp"]http://www.w3schools.com/css/default.asp[/URL]

Member Avatar for javaAddict
0
122
Member Avatar for tknopriest

You don't run the programs, you call the methods. If the other programs are inside a main, then take that code and declare it as a method and call the method. For arguments, You might want to add some JTextFields. Check the API for JTextFields. An example on how to …

Member Avatar for tknopriest
0
77
Member Avatar for Bheeman89

These lines are incorrect: [CODE] GetBookDetails(); newBook = new Book (IDNum, Title,Author,Publishr,CatNumPublicationYr,returnDate,BookStat,ISBN); [/CODE] with the GetBookDetails you get all the date from the gui, but when you call the "new Book" you "erase" the previous object and replace it with the new one. At the next lines the [I]newBook[/I] doesn't …

Member Avatar for javaAddict
0
533
Member Avatar for JavaStudent23

[QUOTE=JavaStudent23;1047111] Let’s say they get on the bus on ‘stop 3’ and go to ‘stop 9’, how would I code this? [/QUOTE] From stop 3 to stop 9 there are: 3,4,5,6,7,8,9 stops. The first doesn't count because the passenger has just entered the bus so you can not charge him …

Member Avatar for javaAddict
0
125
Member Avatar for frankycool

Because you are saving the object as binary data not as text. You are serializing. You cannot open the file and view it. If you want to read it then use the opposite way. FileInputStream ObjectInputStream If you want to save it as text then use BufferedWriter, but it needs …

Member Avatar for javaAddict
0
219
Member Avatar for kjiu
Re: Date

What is the editor? The code that generates the date seems fine.

Member Avatar for javaAddict
0
69

The End.