713 Posted Topics
Re: There are a few possible problems I can imagine here, but I don't know which one it'll be without seeing the code. One is something like this: [CODE] public class ThisClass { public static int intArray[3]; public boolead theMoonIsMadeofGreenCheese = true; public static void main (String[] args) { while (theMoonIsMadeOfGreenCheese) … | |
Re: What skills do you want to work on? What sorts of things have you done so far? There are a lot of possibilities. Conway Life is a pretty good place to play: easy to get into and pretty open-ended. You can add a lot of features, you can tart up … | |
Re: [QUOTE] System.out.println(Car.getCounter());// why to put this statement again after the variable cars was defined to be null?[/QUOTE] The variable cars points to an array of objects, each member of that array is an object of type Car. That array might contain, for example, Ram's Tata Nano and Guiseppe's Fiat and … | |
Re: Prem - you need to understand what static means, to start with. "Static" means "relating to the class, not to an object". A static field of a class is a value associated with the class, and not to any object of that class. An instance field is a property of … | |
Re: Put the body of your if statements in curly braces. [CODE] if(al >= 10001) ir = .075; // this line is the only one in the if i = al*ir*nmp; // this always executes ma = ad/nmp; // so does this else if ((al < 10000) && (al >= 6001)) … | |
Re: Norm - he's using the punctuation as a delimiter. He's actually getting three tokens, as you'll see if you run the code. (put in a counter if you don't believe me!) So the problem is, how do you remove a specified substring from a String. There are a few ways … | |
Re: First of all, I couldn't see any reason why you wouldn't get values assigned, so I ran this (the only changes I made were to make keyboard an instance of Scanner and to add an iteration at the end to print out the values). It assigned seven values for seven … | |
Re: This is not a mortgage calculator with a GUI, this is a GUI that calculates mortgages. Consider yourself grumbled at. Now, it doesn't calculate, you say? [CODE]private void getCleanScreen() { throw new UnsupportedOperationException("Not yet implemented"); } private double getFigure(double mortgagefigure) { throw new UnsupportedOperationException("Not yet implemented"); } private double getPayment(double … | |
Re: One problem I see is that you're trying to initialize a String with a char value in line 12. Single quotes ('') enclose a char, double quotes("") enclose a String. The rest of your error messages aren't making immediate sense to me, but try fixing that and see what happens. | |
Re: [deleted - duplicates a previous post] | |
Re: I didn't even have to count lines - I just looked for the line with the ridiculous number of parentheses, and there's the problem. udscrick - For each '(' you need an ')'. Work your way out from the center of the expression - the first thing that's evaluated - … | |
Re: If you read up on "Generics" - just search on "java generics" - you'll learn an awful lot about this syntax and why it was added to the language. | |
Re: This is a pretty difficult problem, actually. The applet security model is based on the applet running in total isolation, so it can't really communicate with the world. There is a way to do it, but it's very clunky and really a last-ditch solution. I understand that servlets offer some … | |
Anyone played with the jxl API before? It's a tool for read/write access to Excel spreadsheets - a little bit dodgy, but it works. I wrote a piece of code for my brother using this a few months ago, and now he's starting to see a warning message, which is … | |
Re: You're referring to a class called Node, but the compiler can't find it. Do you have that class defined somewhere? Maybe in a class called Node.java? Good to see you're working on linked lists, by the way. Data structures are fun. | |
Re: What do you want to know about inventory management programs in java? If you just want to know "about" them, there's always google. | |
Re: And oddly enough, most of them say more or less the same thing... | |
Re: Learn both. Python is a breeze to learn, once you get used to the significant whitespace (I had horrible flashbacks to vicous and invisible bugs in makefiles, but it's actually okay). Perl is obnoxious and lovely and lots of fun. Python scales up better - you do't really hear about … | |
Re: I'm having a hard time understanding what you want to do, in detail, but it does sound like a complex problem any way I try to understand it. Are you trying to do something to find a bus route from point A to point B? (ie, I'm at 3 Main … | |
Re: An interface is a contract between you and the compiler. The compiler will allow that your class will stand in for an X if you implement the X interface and provide all of the methods that interface demands. An abstract class is an actual class which you can extend, but … | |
Re: You need another set of curly braces surrounding the whole mess. Like so: [CODE= Java] public class Lists { static String[][] la = {{"a", "n", "s"}, {"1","2","3"}}; public static void main (String[]args) { for (String[] sa:la) for (String s:sa) System.out.println(s); } } [/CODE] | |
Re: a) We have no idea what sort of work you've done or what you're interested in doing b) We have no idea of what level of project you're looking for, or what sort of time commitment you're looking to set c) If you're pursuing a degree, coming up with a … | |
Re: Reagan.com - The first ISP to run with no memory whatsoever... | |
Re: Good books... Dunno, but Lewis and Loftus was a reasonably good intro, covered the basics pretty well, and folded in the graphics part well. Very weak on the theory, but you'll want to get that later anyway. Switch is a language construct, derived from C and probably earlier languages, which … | |
Re: Perhaps you should write it in a language you know, then. (You are free to use a programming language of your choice, after all) | |
Re: Pick one, it doesn't matter which, and be good at it. Once you've managed that, pick up the other, it won't be hard if you've really understood the first. Write lots of code, and you'll find that learning new languages is not terribly difficult. Using them might be - if … | |
Re: If you're using the console, you're on the right track. Your only trouble is that the Scanner.next() method only seems to grab non-null input followed by a return. Just the return won't do it. Try Scanner.nextLine() Tong's solution is worth understanding when you get into a GUI, but it looks … | |
Re: There's a lot of literature on the limitations of floating-point arithmetic (google "floating point arithmetic" for a sample) so I won't try to replicate what smart people have already said well, but if you read down some of the stuff that's been written you'll get a pretty good idea. The … | |
Re: This certainly should work, there's no errors I can find and it compiles okay here. "Illegal start of type" suggests that there may be a problem in the boilerplate. Check to see that you have the closing square bracket on your main() declaration: [CODE] public static void main(String args[]) // … | |
Re: I'll take a stab at this, hoping that any errors or omissions will be remedied by other members. Final simply means that once the variable is assigned, it may not be reassigned. That is, it is a constant. This is useful for two reasons. The first is performance: the compiler … | |
Re: So you want to parse an infix expression? This can get complex. For example, the expression you've given, 12+3*5-7 has to be done as 12+ (3*5) - 7 for the correct result. Order of operations gets tricky. But for your first step, you want to scan the input. The easiest … | |
Re: Sure, if it's an array of Strings. What sort of array have you got? | |
Re: ...or based on the second column if you want the columns to be right justified. What sort of input does gnuplot want? Fixed-width, delimited? | |
Re: Okay, you're not really calling any of those methods except the getInput one, and that's kind of weird. In the input, you want to set choice to something (right now, you're reading into input and then overwriting it immediately). Once you have an input and a choice, you want to … | |
Re: I don't see the multidimensional part. This looks like you're talking about an array of Item objects, where an Item has, let me guess, String name, int stockNumber, double price, int qty? Whatever it is, an Item can be put in an ArrayList<Item>, which will expand as you need. Or … | |
Re: You can get any of the characters in the string with String.charAt(), so all you need is to generate lists of integers. The lists should use each of the integers (0..length-1) exactly one time. So you need a method that returns a randomly shuffled list of integers from (0..n). You … | |
Re: Yes, that's much clearer, and the compressed style should be avoided. However, the posted code should compile and run in Java. Was there some sort of question about it? | |
Re: It doesn't look like your main() method is doing anything. Is this an omission, or is this the actual code? If this is the actual code, try putting a call to the printLoop method in the main method and see what happens. (I assume from the presence of the main() … | |
Re: Har To save the repeated checking, you might try one of these methods: 1) Make an array of booleans and mark them "true" as you draw them. Generate a random integer, and check it against the list before you use it. 2) ArrayList can store Objects, which can be removed … | |
Re: Okay, this is not a great suggestion but if I had to do this TONIGHT and couldn't wait for a better idea, I'd try joining each file into one long string (with some separator, like, oh, newline or something) and putting them into an array of scalars. Then when you … | |
Re: I used to be superstitious, but I heard it was bad luck, so I gave it up. | |
Re: There are two loop structures that you can use in Java, the while and the for loop. Do you know how to use these? If not, you should probably consult one of the 1.2 bazillion references that are available on the web, some of which are mentioned at the top … | |
Re: Okay, you want it to handle decimals. You can read a decimal, right? You can take the string "123.456" and parse it into a double? Okay, you could read that in a couple of different ways, but the easiest is "one hundred twenty three point four five six." So take … | |
Re: String.split() returns an array of Strings, and you know the indexes that you want to save (6-8). So there's at least one simple way to do it: make your new array of String[3] and walk through it, putting the first value in the first slot, the second value in the … | |
Re: Four, if you're counting the Graphics context. | |
Re: So the value returned by getItemCount is the data from the scanner? It's hard to see in all this, but maybe that's the case. If so, it's an int, there's no carriage return there. That suggests to me that the value from the scanner is processed elsewhere, most likely in … | |
Re: dec /= 16; is equivalent to dec = dec/16; This is a standard short form for arithmetic operators. | |
Re: pal seems to mean two different things here. Review the initializations and the input portion of the program, and see if you can clear that up. | |
Re: The unary ++ operator comes in preincrement and postincrement flavors. You used (as you noticed) the postincrement version, which does the ++ after it reads the variable. j=i++; is equivalent to j=i; i+=1; If you did a preincrement, you would indeed start from 1. The preincrement operator is like this: … |
The End.