1,963 Posted Topics

Member Avatar for BobBrown

ClassA: [CODE] public static double add(double a, double b) { return a+b; } [/CODE] Main [CODE] import java.util.Scanner; .................. Scanner scan = new Scanner(System.in); // print message for user to enter input String strA = scan.nextLine(); double a = Double.parseDouble(strA); // print message for user to enter input String strB …

Member Avatar for BobBrown
0
70
Member Avatar for izzy234

As far as the error handling you are already doing that. If you enter something other than a number, then the method: Integer.parseInt, will throw an exception and the code will "go" inside the catch. You don't need to check anything: [CODE] public void actionPerformed(ActionEvent e) { try { int …

Member Avatar for javaAddict
0
138
Member Avatar for helpwithjava88

[QUOTE=oruff;1081422]java is not downloadable. Its illegal.. you will go to prison for that mate!!!![/QUOTE] Java is down loadable and free. Why are you spamming other people's threads like this?

Member Avatar for javaAddict
0
214
Member Avatar for NickT80

You need to add get, set methods in your class in order to have access to the private variables: [CODE] public int getRank() { return rank; } public void setRank(int rank) { this.rank = rank; } [/CODE] The same for the title. Do you know how to sort an array …

Member Avatar for javaAddict
-1
85
Member Avatar for alkeshtech

[CODE] public static Object convesrion(Object obj, String s) { } [/CODE] If you search the API for reflect and look at the Class class, I think that you can find methods that: Using a String create a Class instance of the given type. Methods that check if something can be …

Member Avatar for javaAddict
0
99
Member Avatar for GiRL,IT

[QUOTE=GiRL,IT;1074816] I can write this code but I can't Complete it [/QUOTE] As [I]masijade[/I] said post what you have done so far and we will see what we can do for you.

Member Avatar for GiRL,IT
-2
156
Member Avatar for deecy1

[QUOTE=deecy1;1079679]Assuming a one dimensional integer array a[] has been declared and created with 100 elements: for (int i = 0; i<=a.length; i++); a[i] = 5; Assuming int b [] [] = new int [3] [3]; b[1, 1] = 5; Strings students[] = {Pat, Tom, Mary, Anne};[/QUOTE] Where you the one …

Member Avatar for javaAddict
0
95
Member Avatar for sulthana

[QUOTE=gunjannigam;1079354]Scanner br = new Scanner(System.in); int num = br.nextInt(); Integer a = Integer.valueOf(num); System.out.println(a.toBinaryString(num)); System.out.println(a.toOctalString(num)); System.out.println(a.toHexString(num));[/QUOTE] The toBinaryString and the other methods are static, so you don't need to create a new Integer object. What's the point of using the object created if you are going to pass as parameter …

Member Avatar for javaAddict
-1
148
Member Avatar for ravikiran032

Try this: [URL="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html"]Integer[/URL] int is 'smaller' than long so it can fit inside a long. If you write this: [ICODE]double d = 1;[/ICODE] wouldn't be correct? But it is like putting an int inside a double. It will 'fit' Also from the link provided you can find the max integer …

Member Avatar for masijade
0
2K
Member Avatar for Xamas

If you look the String API you will find a method that converts the String into a bytes array. I don't know though if this is going to be useful for you.

Member Avatar for javaAddict
0
157
Member Avatar for dsmush

First of all you have some spaces at the query that will not get you right results: [ICODE] "select * from members where username = ' "+username+" ' " [/ICODE] Should be: [ICODE] "select * from members where username = '"+username+"' " [/ICODE] Second: the "ResultSet" is the name of …

Member Avatar for javaAddict
0
507
Member Avatar for rizzo18

The error is pretty obvious and has nothing to do with sql: [QUOTE] unreported exception java.sql.SQLException; must be caught or declared to be thrown [/QUOTE] You are calling a method that throws an exception, and you don't catch it. I mean why did you surround the [ICODE]DriverManager.getConnection[/ICODE] with a try-catch?

Member Avatar for rizzo18
0
2K
Member Avatar for vishva ransika

Whether it is for combobox or something else, it is irrelevant. What you need is a way to read the info from the database and put them into a list (Vector). Then you can use the data into the Vector and put wherever you want (JComboBox) Search this forum, there …

Member Avatar for craaazy123
-1
82
Member Avatar for saisindhu.v
Member Avatar for javaAddict
0
42
Member Avatar for the_Famous

First of all, line will never be null so you don't need to check that. By doing this: [ICODE] while (scan.hasNext()) { ... [/ICODE] You make sure that there is a next line in the file. Also what java version are you using because the contains method was added at …

Member Avatar for javaAddict
0
103
Member Avatar for dahliababy

The comments in the methods tell you exactly what you need to do. All is needed is some if statements and reducing or increasing the mylocx or mylocy by one.

Member Avatar for JenniLei
-1
103
Member Avatar for beforetheyknew

A Driver class is nothing special. It's just a name, and it means the class in which we call all our methods. The class with the main method that we call in order to run the application. [CODE] class Methods { public static int add(int a, int b) { return …

Member Avatar for javaAddict
0
153
Member Avatar for TheRekz

first of all what the javascript methods that you have at the onclick do, and second why don't you submit without the onclick() ? Since it is type="submit" once the button is clicked the form will be submitted anyway.

Member Avatar for javaAddict
0
523
Member Avatar for nillsource

Use these classes: JMenu JMenuBar JMenuItem check the api for them. The ideas is: You create one [B]JMenuBar[/B]. You create some [U]JMenus[/U] and you add them to the one [B]JMenuBar[/B]. You create some JMenuItems and you add them to your [U]JMenus[/U] Also there is this: [URL="http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html"]http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html[/URL]

Member Avatar for javaAddict
0
128
Member Avatar for divya2909

[B][U]1) Have you read the rules of this forum before posting?[/U][/B] 2) Start by creating objects with properties the columns described at the tables. 3) Read about the Vector class. 4) Will it require a database?

Member Avatar for divya2909
0
76
Member Avatar for may781

[QUOTE=masijade;1072509]Alright, whoever voted that down be man enough and stand up to admit to it (which is probably the reason (s)he didn't use the "rep" link, as that transmits the userId along with it). Who was that didn't like the fact that it was pointed out the user crossposted, without …

Member Avatar for javaAddict
0
106
Member Avatar for lil_panda

Use the Arrays class: [URL="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Arrays.html"]Arrays[/URL] Signature: public static void sort(Object[] a) [CODE] String [] arr=new String[5]; //put stuff into the array. Arrays.sort(arr); [/CODE] The sort will take any array with Objects as long they implement the Comparable interface and they can be compared with each other. The String object does …

Member Avatar for gregoryalussier
-1
729
Member Avatar for JavaOwnsMe

So you want us to read to you the code line by line. Do you know how methods are called? If yes, it is pretty simple: Objects are created and their methods are called. Have you tried reading the API or reading a tutorial on how to creat guis?

Member Avatar for BestJewSinceJC
0
160
Member Avatar for joewazen

What you ask is rather difficult. In order to know when the table has been updated, you need to add triggers to your table. Then write a PL/SQL function that executes when the "trigger" is triggered. The rest are a bit blurry to me since I am not familiar with …

Member Avatar for MxDev
0
146
Member Avatar for Perveance

Because you add it only to vector and not the JList: [CODE] gf.vf.add(file); [/CODE] You added it successfully to the Vector but where is the code that adds it to list?

Member Avatar for Perveance
0
244
Member Avatar for NickT80

Your brackets are all over the place. You open them and you don't close them correctly. Start over and this whatever opens close it, and write code inside it. At the while loop you don't update the len value inside it. You say that "Please enter at least 15 characters" …

Member Avatar for MxDev
0
134
Member Avatar for abhay1234

This is what is displayed: [CODE] <option>[B][COLOR="Green"]MCA[/COLOR][/B]</option> [/CODE] This is what it is sent with the request: [CODE] <option value="[B][COLOR="Red"]MCA[/COLOR][/B]">MCA</option> [/CODE] Meaning that there will be cases that what you display is different from what you want to sent: Example: [CODE] <select [B][COLOR="Green"]name[/COLOR][/B]="product"> <option [B][COLOR="red"]value[/COLOR][/B]="000-001">Product Name 1</option> <option [B][COLOR="red"]value[/COLOR][/B]="000-002">Product Name …

Member Avatar for javaAddict
0
136
Member Avatar for ZoomZoom
Member Avatar for nola_Coder

[CODE] for (int i = 0; i < adj2.length; i++) { for (int j = 0; j < adj2.length; j++) { path += [B][COLOR="Green"]adj[i][j]*adj[j][i][/COLOR][/B]; } } [/CODE] The above always returns 0. If you run the code by hand you will see that the above snippet, never has 2 elements …

Member Avatar for nola_Coder
0
170
Member Avatar for silveram
Member Avatar for javaAddict
0
92
Member Avatar for Pranesh_Ashrit

Have a login page. How else will you be able to distinguish them apart. There is a tutorial in this forum

Member Avatar for javaAddict
0
108
Member Avatar for P00dle

No, args[0] is not null. The array args has length 0. So the args[0] gives you the exception since there is no '0' element; the length of the array is 0. The elements of the args will [U]never[/U] be [ICODE]null[/ICODE]. Depending on the number of parameters you pass the array …

Member Avatar for P00dle
0
77
Member Avatar for Samyx

[CODE] public class ArithmeticOperatorImpl implements ArithmeticOperator { .... } [/CODE] [CODE] public class OpIterator implements OperatorIterator { .... } [/CODE] Then create the OperatorFactory class that creates ArithmeticOperatorImpl objects and returns them based on the input

Member Avatar for javaAddict
0
87
Member Avatar for asadc

[QUOTE=asadc;1063280] java.lang.NumberFormatException: For input string: "None" [/QUOTE] Doesn't this give you a clue? You are trying to convert the "None" into a number, probably with Integer.parseInt(...) Whenever you call this: Integer.parseInt(...) you need to have a try-catch in order to handle the error if it is not a number. The …

Member Avatar for javaAddict
0
748
Member Avatar for TheDLSyrnyk

Assuming that the sentence is stored in a String variable, why don't you check the String API. We might find something there that could be useful. PS. I didn't notice that this is my 1[B][COLOR="Red"]666[/COLOR][/B] post!

Member Avatar for javaAddict
0
134
Member Avatar for Shotty

None of your codes are correct. As stated in your previous thread by me, your initial code was correct. But it seems that you followed an incorrect suggestion by another member. The new line character should be placed outside the inner loop: [CODE] String r = ""; for(int i =1; …

Member Avatar for javaAddict
0
79
Member Avatar for mimsc

[URL="http://www.w3schools.com/tags/ref_urlencode.asp"]http://www.w3schools.com/tags/ref_urlencode.asp[/URL]

Member Avatar for mimsc
0
279
Member Avatar for Shotty

[QUOTE=tjsail;1062094][CODE]for(int i = 1; i <= rows; i++) { for(int j = 1; j <=columns; j++) r = r + " _"; r = r + "\n"; }[/CODE] Your nested "if" statement's statements are not defined correctly, and/or your indenting is problematic. I BELIEVE your code should look like this: …

Member Avatar for javaAddict
0
133
Member Avatar for Afupi

First of all the format String must [U]not[/U] change. It is the one the determines how the output will be formatted: [CODE] outString = String.format(outString,%6d,%16f,i,numArray[i],"\n") //or outString = outString+String.format(%6d,%16f,i,numArray[i])+"\n"; [/CODE] After the first loop you change the outString so the rest of the results will be all over the place. …

Member Avatar for Afupi
0
253
Member Avatar for samoo

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 about the gui. Keep the node class and create an AVLTree class. The Tree …

Member Avatar for javaAddict
0
1K
Member Avatar for _dragonwolf_

Use a for loop, to loop through the ArrayList and print its elements instead of the System.out.println(row1)

Member Avatar for ~s.o.s~
0
112
Member Avatar for nlanka

In your class the "s" input is the one that has the values not the Score. I mean it is the "s" that you pass as parameter, then you put values from s to Score. Why on earth are you checking the values of Score if you put the values …

Member Avatar for javaAddict
0
108
Member Avatar for COKEDUDE

[CODE] for (int i = 0; i < itemCount; i++) contents += cart[i].toString() + "\n[B][COLOR="Red"]"[/COLOR][/B] contents += "\nTotal Price: " + fmt.format(totalPrice); [/CODE] First of all, I think you missed a " after the \n inside the loop. Secondly, cart[i] is an int. Where did you see written that ints …

Member Avatar for javaAddict
0
202
Member Avatar for saikatroy1985

[QUOTE=peter_budo;1059878] PS: Members, please do not point obvious resource.[/QUOTE] And I was wondering why, [U][B]especially you[/B][/U], didn't point him to that obvious resource. :)

Member Avatar for peter_budo
1
100
Member Avatar for nobodycool

Even though from your code you have figured out on your own how to use array of objects here is a small example: [CODE] Music [] array = new Music[3]; // array is an array and it is not null // Its elements are so you need to initalize them …

Member Avatar for javaAddict
1
146
Member Avatar for sahity1a@yahoo.

From the original array count how many people there are for each personality type and have those values be in 4 variables. Use those 4 variables to create 4 arrays and then loop again in order to populate them. As for the rest we will not give it another thought …

Member Avatar for javaAddict
0
101
Member Avatar for timaquerra

First of all learn the difference between PreparedStatements and Statements. You initialize the prepareStatement with a fixed query (wrong) and then you call this: [ICODE] pstmt.setString(1, Cust_Id); [/ICODE] [B][COLOR="Red"]????[/COLOR][/B] You don't have an argument at index 1 at the query. Where the [B](1, Cust_Id)[/B] will be applied[B][COLOR="Red"]????[/COLOR][/B] And if we …

Member Avatar for ~s.o.s~
0
198
Member Avatar for jeby
Member Avatar for 9107you

First of all you don't say what is your problem and what is your question. You just post code you have written. Second of all, the main method is void, nad like any other method that is declared void cannot return anything so this is wrong: [CODE] if (tax > …

Member Avatar for javaAddict
0
120
Member Avatar for dorotalp91

[CODE] boolean b = true; do { .... //do something with the b variable .... } while (b); [/CODE] The loop will terminate when the answer is found.

Member Avatar for donaldw
0
108

The End.