713 Posted Topics
Re: That code looks like it should compile okay - did you maybe have a command-line typo when you went to compile or run? | |
Re: [CODE] while (frontteeth <=0); ... while (rearteeth <=0); [/CODE] The semicolon at the end of this line is an instruction. It means "do nothing". So if frontteeth or rearteeth is le 0, it'll hang at one or the other of these points. For input validation, I think a do...while loop … | |
Re: For this assignment your constructors aren't actually constructing a class, they're demonstrating the order in which constructors are called, and how the code executes. So there isn't really a problem to solve: you're just going to write four dummy classes, each of which extends the previous one and has a … | |
Re: It won't hurt to try to do a little work for yourself. Might even do you some good. Go on, give it a try. | |
Re: [QUOTE]I'm now having a problem with trying to identify if there are any cars on a specific lane, if so, then do some stuff, such as stop behind or slow down etc. [/QUOTE] It sounds like what I'd be looking for would be for the Lane to tell me whether … | |
Re: Next thing you might want to do is a little research: what does "static" mean, and why did making your method "static" make the code go? How could you have solved this without declaring that method as static? Quick and easy answers are nice, but you might as well take … | |
Re: I'm pretty sure it's not correct. What you're comparing here is identity. This returns true only in the case that the address contained in this.a is the same as the address contained in o.a. You're comparing pointers. So if you declare this.a to be a new Point(5,5), and you'd previously … | |
Re: Are you getting the return value from the final dialog? Use that to control a loop. [CODE]boolean again = true; while (again) { all of that; if (dialog returns YES_OPTION) { do one thing} else if (dialog returns NO_OPTION {do another thing} else { uh-oh, this shouldn't happen!) }[/CODE] | |
![]() | Re: [CODE]for (i = 0, i < 3; i++); for (j = 0; j < 3; j++);[/CODE] These lines simply count to three, twice. |
![]() | Re: Your second loop is going to j<=l - since l is array.length, this takes you over the edge - you're trying to access array[0][2] Change the <= to < and you should be okay. ![]() |
Re: You've got the output section within the for loop. That means that each time through the loop, it gets two Strings and an int, calculates a char for the grade, and prints. If you end the for loop before the printf statements (move one of the right curly braces up … | |
Re: [CODE] public Password(String password) { // initialise instance variables password = userPassword; } [/CODE] You want these the other way around. This line should assign your parameter (password) to the instance field (userPassword) so the rest of the class can use it. Your isValid method looks troublesome to me. For … | |
Re: Why are you passing in JOptionPane.CLOSED_OPTION? That should be a return value, shouldn't it? It's probably got the same value as the input option you're looking for (per the API, you want an option type: optionType - the options to display in the pane: DEFAULT_OPTION, YES_NO_OPTION, YES_NO_CANCEL_OPTION, OK_CANCEL_OPTION) That won't … | |
![]() | Re: Is it just me, or does this smell like a homework assignment to anyone else? You can only use one layout in a panel at a time. You can use multiple panels, nested, with different layouts, but a single Panel gets a single LayoutManager, as far as I know. You … |
Re: [QUOTE]The program must simply ask the user to type in a text[/QUOTE] Well, if that's all you need, it's easy enough: [CODE] public class TooLazyForWords { public static void main(String[] args) { System.out.println("Please type in a list of words separated by spaces"); } }[/CODE] There you go. Requirements met, as … | |
Re: To get it to line up like your image, you'll need to use the c-style printf() function. Since this is well documented by Sun, I'll just briefly review it. printf is based on the function of that name in the C language. It allows in-line interpolation of variables with some … | |
Re: Not sure what you're asking. A typical gui might have a JFrame, which would have a main JPanel into which you'd put your components. You might use nested JPanels for organizing components (a button panel for your JButtons, for example). You might also find that you use JTabbedPanes or JScrollPanes … | |
Re: (This is based on my experience with Java - other languages may vary) A class is the template from which an object is created. A class defines object, an object instantiates the class. The main difference is how they go about existing on the stack. When a class is loaded, … | |
Re: Some more thoughts: -Second the (CODE) button in the quick reply window. -The (THREAD) button, in my dream world, would show a list of recently-visited threads to choose from, or accept a pasted URL. I'm not sure what the corresponding ideal behavior for (POST) would be, but probably selecting a … | |
Re: If the purpose of the assignment is to learn to use the library methods, then using the library methods is the right way to go. If the purpose of the assignment is to learn what lies behind the library methods, then you have to do something more like the K&R-type … | |
Re: First of all, stop with the smileys, they're aggravating. So you're having trouble with data structures - is that because you're having trouble getting the concepts, or because the coding is difficult, or both? If you understand what a linked list is, but you have trouble writing one, you have … | |
Re: As long as we're wishing, can we get rid of the Salvation Army bellringers? | |
Re: The simplest thing would be to open up a new JFrame to display screens of help. How you organize the information will depend on how much there is, but let's suppose that you need to explain the rules, the controls, and the interface with the machine (saving a game, settings, … | |
Re: Just out of curiousity, what's a tower defense game? | |
Re: Curiouser and curiouser. When I set it up, I put a timer around the first loop. For any simple numeric value in the test condition of the first loop, it optimized out to zero millis and about 1 second for the second loop. However, when I set the test condition … | |
Re: a) please don't bump old threads to ask new questions b) if you have a question, please ask it clearly. If you want help with something you're writing, please let us know what particularly you need help with - otherwise, someone's likely to think you're looking for someone to do … | |
Re: [QUOTE]Write a program to calculate the number of words,tokens,keywords,userdefined functions,system function for your java program.[/QUOTE] Okay, did that. What should I do next? | |
Re: That's not going to be a simple one. The contents of a text area are stored as a single line, with wrapping provided by the component, so there isn't a method that'll just return an arbitrary line. I would probably set the font to a monospace and see if you … | |
Re: Have you tried looking to see what is in $VarComparison after this assignment? [CODE] my $VarComparison = $Sheet->Cells($row,$VarICN_Col)->{'Value'};[/CODE] Just a thought. | |
Re: In case there is any confusion, I want to stress that the resemblance between try/catch/finally and if/then/else is purely superficial, and the two should not be confused. As Sean noted, the finally clause always executes (barring some extremely complex and extremely unlikely constructions that code lawyers have come up with), … | |
Re: I seem to recall that Eclipse won't automatically include non-java files in a build. If I'm remembering correctly, you'll have to write an ant build file to get this to go. However, I'm not a real heavy-duty Eclipse user, so it's possible I'm wrong on this. | |
Re: Wait. Be ready. You will be contacted when it is time. ![]() | |
Re: The simplest thing would be [CODE]System.out.println(123); System.out.println(12); System.out.println(1); System.out.print("\n\n"); System.out.println("help me..");[/CODE] Meets your stated requirements, anyway. Anything else we can help you with? | |
Re: To test whether you understand the code after reading James' explanation, there's a very simple change you can make to this which will eliminate about half of the work this program has to do. The change is very simple, it involves one arithmetic operation inserted in the right place. Can … | |
Re: [QUOTE]note: Line numbers are matched correctly [/QUOTE] I don't believe they are. Line 32 in this numbering doesn't call PickWord(). I don't know exactly which call you're looking at here, and I don't know which line triggered the NoSuchElementException, but that exception is thrown by a Scanner when you try … | |
Re: First of all, if you're using "println", it'll put a carriage return at the end of the line. System.out.print() will just output the string, without the carriage return. That'll help you format your output the way you want. There's also printf(), but that's a little complicated, and you don't really … | |
Re: What do you mean by "it won't work"? What is it doing or not doing, and what do you expect instead? Is it compiling? Does it run? What happens when it runs, assuming it does? If it compiles, then that would mean that ButtonWatcher is implementing ActionListener correctly. That only … | |
Re: The reason for that error is not hard to determine: the operator < can only be applied to numeric types. String is a class, a String is an object, they can't be compared in this way. You want the compareTo() method. Read up on Comparable if you're not familiar with … | |
Re: James - unfortunately, for Mac users who still use 10.5.8 (which is a large number) there are a lot of issues with 1.6, especially around applets. I've seen this now on two completely unrelated projects: if you're writing applets, you have to expect that Mac users will be unable to … | |
Re: Sorry for the pseudocode, but I'm not going to write your homework for you. You need to read the file and split each line into its component parts. The parts are delimited by spaces. Assuming that this is a consistent format, we can do this: [CODE]declare five arrays; // 1 … | |
Re: [QUOTE=unknown12;1432055]i fixed this up so it works however when i enter in a negative # It Doesnt tell the user it wont work. any sugestions?[/QUOTE] Sounds like you want an if statement. If input is less than zero, print some sort of warning, otherwise go ahead and execute the program … | |
Re: [QUOTE]clearly there is a need. i just outlined the need.[/QUOTE] Means and ends. You don't need a preprocessor, you need a technique for getting your program to exhibit the behavior you want. The preprocessor is the means you'd use in C++, that's all. In java you'd do this a bit … | |
Re: If you want commas within your fields, you'll probably want to use a different delimiter. Excel is pretty flexible on this, if that's what you're importing to. Semi-colon, space, tab are standard enough to get radio button on their import tool, but you can specify whatever you like. Pick something … | |
Re: Gentlemen, or ladies, as appropriate, let's please try to be a little subtle here. Here's a New Year's resolution for you: in the coming year, I will help people find a solution, not give them their solution. Now, javap - what have you tried so far, and what has been … | |
Re: Simple geometry, really. Suppose the images are quadrilaterals. If any point of image1 is between the top and bottom of image2, and also between left and right of image2, then you have a collision. If image2 is a circle, it's still simple - if the pythagorean distance from any point … | |
Re: Let's start by making your life a little easier. There's no reason to have the same method 26 times. Can you see any way to make your `getButtonA()` method generic, so you can use the same method for all of the characters? I'll give you a hint: there are only … | |
Re: It would probably be a mistake to think of "public"and "private" as relating in some way to the distinction between global and local scope. The notion suggests a bit of confusion about object-oriented programming. Public and private fields of a class are all "global" in that they can be called … | |
Re: vi and javac is my environment of choice, but I use Eclipse at the day job because they require me to work on their Windows machine. Eclipse is not terribly painful, but I find its attempts to help me quite irritating. I'll write my own code, thanks very much, I … |
The End.