1,678 Posted Topics

Member Avatar for suretd

These are the two important pieces of code: [CODE=Java]public int setCreditHrs() { return creditHrs; } if(!student.setCreditHrs(hrs))[/CODE] Mistakes: 1. As you can see, in the first piece of code, you have declared your method as "public int setCreditHrs()". What this means is that the method returns an int (where it says …

Member Avatar for BestJewSinceJC
0
271
Member Avatar for grisha83

IntNode cur = head; IntNode prev = cur; Doesn't make any sense. You're essentially assigning cur = head, then prev = head. Do you mean to say: IntNode prev = cur; IntNode cur = head; ?????

Member Avatar for grisha83
0
67
Member Avatar for f.damati

@bluerose I think javaAddict conveyed that same point with his post. Please don't repeat people for the sake of posting (unless you're adding something to the discussion), otherwise, you'll become like adatapost.

Member Avatar for javaAddict
0
177
Member Avatar for mysong
Member Avatar for Pogo24

There are also a lot of jobs that are related to computer programming, that you might not think of if you are focusing strictly on coding. Some people here who are in industry might be able to give more examples, but here are some topics to look into: Software configuration …

Member Avatar for Stinomus
0
98
Member Avatar for lyxus

We can't "give" you the code. In a BST, numbers greater than the value of the current Node are in its right child, and less than are in its left child. Therefore, if you're looking for a certain value/Node, just search logically until you hit that Node. Then return it.

Member Avatar for BestJewSinceJC
0
65
Member Avatar for fuzzyrose

Linux is an operating system. Java is a programming language. Coincidentally, java should run the same on Windows and Linux (don't count on it) but if this was a C++ program, you would not have the same luck.

Member Avatar for kvprajapati
0
238
Member Avatar for Kishorey
Member Avatar for Kishorey
0
126
Member Avatar for lardshow

pitchTarget = lineScanner.nextInt(); // return the next token as a double targetMap.put(taskNumber, pitchTarget); //this is the line that doesn't work Your first line I posted doesn't make sense. The nextInt() method does not return a double, it returns an int. And your treeMap is declared as taking a K, V …

Member Avatar for lardshow
0
101
Member Avatar for JamesKox
Member Avatar for caps_lock

To get the size of a file, you use file.length(). This tells you how many bytes the file is. Is that all you needed to know?

Member Avatar for caps_lock
0
225
Member Avatar for lardshow

for (String name: this.students.keySet()) // line 1 { System.out.println("Student " + name + ":"); // line 2 //this line should call the displayMarks() method from the class student, but whatever i try doesnt work System.out.println(); } In order to call a method of the class Student, you must use an …

Member Avatar for lardshow
0
92
Member Avatar for bluerose

You would just add "\n" to the String you are outputting whenever you want it to go to the next line. Is this even your code? That seems awfully simple to not know for such a complicated piece of code, so maybe I misunderstood your question.

Member Avatar for bluerose
0
135
Member Avatar for JamesKox

No, it does not, because Scanner's hasNext() method does not get the next character, or get anything for that matter. It tells you if the Scanner has any more tokens in its input, and it does not advance past any input. So you'd be sitting in an infinite loop (if …

Member Avatar for JamesKox
0
260
Member Avatar for gabec94

If you want to start a completely new game, then the ideal way would be to have Life set up as a class, and you'd simply create another Object of that class type. Alternatively, you could set all your variables back to blank/however they were initially. But if you're referring …

Member Avatar for gabec94
0
5K
Member Avatar for christiangirl

Personally, my first instinct would be to write a listener method that got the text, counted how many characters were there, and "refused to let more be entered" by setting the text back to whatever was previously there if the user entered too much. That would work, however, my first …

Member Avatar for kvprajapati
0
143
Member Avatar for christiangirl

[url]http://java.sun.com/javase/6/docs/api/java/lang/String.html[/url] What do you think indexOf does? I can't really clear up the problem without knowing what you expect it to do and what it is doing.

Member Avatar for kvprajapati
0
172
Member Avatar for JamesKox

If you want to read from a file and count how many characters are in it, use FileReader or FileInputStream, not InputStream, since you cannot open a File with InputStream. Then use a while loop like they said, incrementing a counter for each byte you read. The final value of …

Member Avatar for kvprajapati
0
2K
Member Avatar for anujsharma

I don't see how this is a question of what function you are using. Generate a pseudo-random number, then use the modulus operator to force your result to be between 0 and whatever. Then use addition to bring that result between 10 and 20.

Member Avatar for BestJewSinceJC
0
117
Member Avatar for lifeismusic434

I don't know that this is the [I]best[/I] way to do it, but why not use a for loop that goes through the String[][] and setValueAt(Object, row,column) to update the JTable.

Member Avatar for lifeismusic434
0
101
Member Avatar for joker21

What do you mean "create the box"? Do you mean a button that the user can click on, or do you mean the window in which your content (the pictures saying buy it) is displayed? Look into how to create and use JFrames, JPanels, Layout Managers, JButtons, and JLabels. You …

Member Avatar for Ezzaral
0
245
Member Avatar for mmmusa

Nobody is going to do your project for you. Either read the forum rules or go away.

Member Avatar for javaAddict
0
219
Member Avatar for Zibo

Did you try calling setSize on the JPanel, then calling getSize afterwards? Also, post your code.

Member Avatar for Zibo
0
191
Member Avatar for MrMackey

How do you plan on using that tool? Looks like more trouble than it's worth. If you have the skill to do this, then by all means. Otherwise code it up yourself. Keep in mind that exchange rates frequently change, so you should not just hard code the current exchange …

Member Avatar for verruckt24
0
86
Member Avatar for Liszt

Judging by the fact that you got the expected output, and not an error, it seems like a safe assumption, doesn't it? If you're concerned about it, run some tests on varying inputs. You'll probably find that it works fine. My guess is that the toLower() function uses the ASCII …

Member Avatar for Liszt
0
209
Member Avatar for MrDiaz

[QUOTE=MrDiaz;867636] setValues() takes all the data from the controls on my UI and sets these values to an Object "Day". So each day has the same properties (hours, landings, solo flying, etc.) I think I'm going to use the Java DB. Quick question, how easy would it be to deploy …

Member Avatar for JamesCherrill
0
192
Member Avatar for BestJewSinceJC

Hi, I'm a fairly good Java programmer, but I have basically no web development experience. I'm posting in the html forum because I know it is the most basic, but I'm sure there are other necessary tools to accomplish this task, please let me know what they are. I want …

Member Avatar for diafol
0
98
Member Avatar for bokz06

[CODE=Java]boolean validChoice = false; while(!validChoice){ //Get the user's input, if it is y or n, set validChoice to true. }[/CODE] You said you "need exception", do you mean you want to throw an exception? If so there are a few ways you can do that. edit: I just realized you're …

Member Avatar for bokz06
0
109
Member Avatar for bokz06

If you're asking if you can output the contents of the JTable into the file, then yes, you can. Using two for loops (nested/one inside the other) go through each row and each column and print whats at the index into the text file. Use a PrintWriter to output to …

Member Avatar for JamesCherrill
0
2K
Member Avatar for squinx22

Are you doing a Huffman Coding project? If not, I don't see the purpose of what you're doing. (In other words, if you aren't doing Huffman Coding, then what do you mean by 'chunk the file bytes into a certain size before writing'? .... I don't see how you'd know …

Member Avatar for JamesCherrill
0
89
Member Avatar for matrix2

Read the forum rules. We only give homework help to those who show effort. Ask specific questions about problems you are having with your code and you will get help. Otherwise, you will not.

Member Avatar for ithelp
0
354
Member Avatar for Lukezzz

[Warning: This is coming from a Java programmer with no C++ experience] Assuming that clicking 'X' generates an event, and C++ has method overriding - override the method that closes the window when the user clicks 'X', and do nothing in that method. That way, nothing will happen when the …

Member Avatar for Lukezzz
0
294
Member Avatar for K?!

[QUOTE=K?!;868009]I didn't know how to access the class held another class, from that class that is held. [/QUOTE] That does not make any sense. Try to clarify? [QUOTE=K?!;868009]The problem now is, when users start working in the program(switching from one panel to another), it keeps on adding panels to the …

Member Avatar for BestJewSinceJC
0
134
Member Avatar for Undream

@ thoughtcoder Profound :yawn: . Next time before you post, try removing any arrogant or insulting language from it. Especially when jbennet has contributed much more to this site than you have.

Member Avatar for BestJewSinceJC
0
140
Member Avatar for grisha83

As hard as I tried, I couldn't find anywhere where you told [I]us[/I] where the problem is. Since we can't read your mind this might be useful information.

Member Avatar for hardik.rajani
0
372
Member Avatar for functionalCode

[QUOTE=evant8950;864347]I'm working on a program to upload some files to an ftp. I created a thread the starts the upload when the upload button is pushed. When the upload button is pushed the GUI freezes because it is uploading. What change would I have to make to get the GUI …

Member Avatar for BestJewSinceJC
0
113
Member Avatar for grisha83
Member Avatar for BestJewSinceJC
0
123
Member Avatar for Rama_Kamisetty
Member Avatar for lkw8888

Use code tags and only post relevant code. I doubt that those huge tables of data are relevant. Your question also doesn't really make sense. What does "stop and wait timeout resend" mean?

Member Avatar for lkw8888
0
256
Member Avatar for AirmanTheGreat

int value = JOptionPane.showMessageDialog(null,"blah"); if(value == JOptionPane.CANCEL_OPTION){ //do stuff }

Member Avatar for AirmanTheGreat
0
175
Member Avatar for number87

In your paint() method, call super.paintComponent(g). It will clear the screen. Alternatively, you could use this piece of code from inside your paintComponent method: [CODE=Java]g.clearRect(0, 0, this.getWidth(), this.getHeight());[/CODE]

Member Avatar for BestJewSinceJC
0
2K
Member Avatar for ramborambo

You could also use a stack to reverse the order. Put them in a stack, then pop them, and for each pop, put the element that was popped into an array. The array you end up with is the original one but in reverse order....

Member Avatar for BestJewSinceJC
0
129
Member Avatar for puk

Post all *relevant* code. You definitely need to have implemented some sort of action listener for the check boxes to even begin making this work. Did you do that?

Member Avatar for BestJewSinceJC
0
88
Member Avatar for giri.pankaj

@OP ignore this, I am asking a question relevant to this thread rather than giving you advice here. . Searching each generated word with a long list of existing words (which might be in thousands) is itself a time consuming task, but you can have the dictionary words put into …

Member Avatar for iamthwee
0
1K
Member Avatar for TaubBaer

For the first error, you're either using a constructor that does not exist, or you didn't properly import the class.

Member Avatar for TaubBaer
0
556
Member Avatar for KirkPatrick

If you must, cast each element individually to the appropriate type. [CODE=Java] public static void main(String[] args) { Object[] ints = new Integer[10]; ArrayList<Integer> list = new ArrayList<Integer>(); list.add(1); ints = list.toArray(); System.out.println((Integer)ints[0]); }[/CODE]

Member Avatar for BestJewSinceJC
0
92
Member Avatar for murrple_1

Why don't you just use the normal way to associate an image with the button? [url]http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-JButton.html[/url]

Member Avatar for murrple_1
0
149
Member Avatar for newcook88

// is the bucket in the table? I don't know, is the table round? // can it be added to the table? Perhaps. // can the bucket be added at its hashed index? If there's nothing else there, why not? // what is to be done if the hashed index …

Member Avatar for BestJewSinceJC
0
128
Member Avatar for freddiecool

Without looking at your code, (gotta be somewhere soon) I'd recommend that you use compareTo to compare the two Dates to each other. If you aren't using the Date class to store your dates, look at the compareTo method for whatever class you're using

Member Avatar for BestJewSinceJC
0
155
Member Avatar for Der_Kaiser

[url]http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html[/url] You would follow the same process as shown there, except create two client sockets instead of one. Then send the same output to both clients whenever it is necessary.

Member Avatar for BestJewSinceJC
0
168

The End.