713 Posted Topics
Re: I'd just like to point out that there may be something wrong with your approach if you think girls are "goals" to be "achieved". Just sayin', you know. Maybe I'm wrong, what do I know? | |
![]() | Re: Does the name of the object matter to you? If you just want to create objects with arbitrary references, use a collection. ArrayList is my usual go-to for this purpose. If you want a String associated with the object, use a HashMap<String, Foo> - where Foo is whatever type of … |
Re: "this" refers to the object wihch is running the method. If you have a local (method) variable shadowing an instance field, you can refer to the instance field by [ICODE]this.variable[/ICODE]. In a constructor, we commonly use parameters to set fields of the object we are creating. It is convenient to … | |
Re: Oh, where's your sense of adventure, James? What's wrong with a compareTo that sometimes returns coin1>coin2>coin1, anyway? I think it adds a little spice to your coding. | |
Re: [QUOTE]First question: is javascript the same as java?[/QUOTE] No, but there's a javascript forum under web development. [QUOTE]if java has while and do while loops[/QUOTE] Yes, all the while and do while you can use. They're on special this week, in fact. [QUOTE]I want the user to input the deck … | |
Re: [QUOTE]Meaningful variable names and comments explaining the goals will help a lot, I think[/QUOTE] Second that. Sit down and explain this program to someone, and every time you get to a variable, listen to how you explain it. That's the name of this variable. If you find yourself wondering why … | |
Re: Are you trying to implement an ArrayList or use the existing library code? If it's the latter, the "codes" would be ArrayList<Type> list = new ArrayList<Type>(); [CODE]list.add(item); boolean b = list.isEmpty(); list.clear(); b = list.isEmpty();[/CODE] | |
Re: [URL="http://oreilly.com/catalog/9780596520113"]Learning Perl[/URL] is the best place to start. Buy it, it's not just a read-it-and-toss-it intro, it's also a good reference for a long while after you're working in the language. [URL="http://oreilly.com/catalog/9780596000271?green=11557207663&cmp=af-mybuy-9780596000271.IP"]Programming Perl[/URL] is extremely good as a followup. I haven't used the Intermediate Perl book, so I can't say … | |
Re: I don't see anything obviously wrong except the missing semi after the return statement and the fact that you're not using Math.min - what is the problem you're having? | |
Re: Simplest possible method I can think of - not the best, but maybe not too bad, either - would be to store each element (text area contents/image file reference) as a property in a properties file, and read the properties file to reconstruct the saved data. You'd have to distinguish … | |
Re: There are a few issues with this code. - The series of if statements starting at [CODE]int[] frequency= new int[9]; if (salary>= 1000.00) { ... [/CODE] is equivalent to [CODE] if (salary>= 1000.00) { ++frequency[array[0]++]; }[/CODE] -Since you're dealing with newly-declared (and unassigned) arrays, the value of each element is … | |
Re: [CODE]String i=df.format(((endTime-startTime)/1000));[/CODE] I assume startTime is a long. (endTime-startTime) produces a long. Therefore (end-start)/1000 is integer division. Integers in java are a closed set under division. What is, for example, 3452342L/1000? You need to convince the machine to divide floating points, not integers. EDIT: in other words, what keikkaishi said. | |
Re: [QUOTE]The real members here is much more than 10 000 though I'm sure.[/QUOTE] I'm not so sure. The regular posters in the java forum are numbered in the low dozens. Then there are the one-shot Johnnies who come in with a question, get an answer, and go on with their … | |
Re: Answering questions, even the questions you've seen a hundred times, requires thinking about the way a language works, or the way a problem is constructed. This is very useful for becoming a better programmer. The first time you explain why it's important to override the hashCode() method if you override … | |
Re: As you've seen, nobody's going to write your code for you, but we can probably walk you through the development process if you need it. What does your pseudocode look like? | |
Okay, I suspect this may be a marginal sort of post here, but maybe folks won't mind too much. I won't be offended if it's deleted, though - if it breaks some rule or other, it should go away, because we don't want to break rules. Anway. People who are … | |
Re: Um... that sounds like it's sort of your job, isn't it? I mean, if can I design an AI capable of doing prescription based on a lab report (something humans aren't all that good at, I should point out) then wouldn't I want to sell that to someone? That said, … | |
Re: In case you happen to have the values at compile time and want to hard-code them, you can also do this: [CODE]int[] a = {1,2,3,4,5};[/CODE] Which creates the array on the right-hand side and assigns it to the array a. But I can't think of a lot of occasions when … | |
Re: Thanks for the pointer to this. I hadn't come across this before. Did six of them before bed last night, in three languages. Brute force solutions, mostly, but I'm going to try to think of more clever approaches before I read the discussion of the problems. I don't know if … | |
Re: No overloading in Java, except what's already in the language (string concatenation by +, for example). Default parameters you could do by overloading the method name. [CODE] public int bogusMethod() { return bogusMethod(5); //call this method using 5 as default } public int bogusMethod(int parameter) { // do some calculation … | |
Re: Try the [URL="http://www.daniweb.com/web-development/javascript-dhtml-ajax/117"]javascript[/URL] forum, they might have better answers there. | |
Re: "But anyway, line 9 you lose all the text before the char you are upper-casing " But that line will never execute: [CODE]{if(i!=str.length()-1&&str.charAt(i+1)>='a'&&str.charAt(i+1)<='z'&&str.charAt(i)==' ')[/CODE] The set of chars a such that [ICODE]a>='a' && a<='z' && a ==' '[/ICODE] is the empty set. | |
Re: Probably you don't want to make a new Scanner each time you print the board.That should go in your setup code, not in "printBoard" For the rest, map out the game in high abstractions. What happens in the game? Well, each player takes a turn until the game is over. … | |
Re: Can do, but won't. Do your own homework, it's good for you. | |
Re: conv is a static method. It doesn't have a "this" - it executes without an object. | |
Re: The stack trace would be useful. However, the problem might be here: [CODE] String url = row.split(",")[1];[/CODE] This gets the second item from the string: if the original string is "XXXXX, YYYY" this would set url to "YYYY". Is this what you intend? If row does not have a comma, … | |
Re: a) yes, possible b) no, not worth doing (not because CS is hard - no harder than any other serious field - but because an online degree isn't worth the paper it's printed on, even if you print it out) c) this thread is seven years old and unrelated to … | |
Re: I'm confused. Coordinates don't move, they'd be pointless if they did. Do you mean you have moving points? If so, Taywin's suggestion is correct. If you have two points, A and B, you have the distance, by Euclid. If you have the time it takes to get from A to … | |
Re: You can certainly store a JPanel in an ArrayList - any object reference can be stored in an ArrayList. I don't know what you mean by "getting an index for a JPanel" though. If you have 40 JPanels and you need to retain references to them, some sort of collection … | |
Re: I may not be understanding your requirements correctly... do you mean to say you want to input integers i and j, then count from i to j by... what exactly? Counting odd numbers? Even numbers? Both? Depending on user input? Your code seems unnecessarily complicated. Rather than trying to find … | |
Re: Ask and you shall receive. That'll bump you up a bit. (unless reputation in this forum doesn't count, I don't pay a lot of attention to reputation and how it works) | |
Re: Can you post the compiler output? It'd help if I could see what errors I'm looking for. | |
Re: Yes. You need to use ordinary file i/o to establish the path to the image (this can be a hard-coded path, or entered by the user, or selected in a file browser, so you have plenty of options here). Then you create a BufferedImage object and try to read it … | |
Re: This line here [CODE]<script language="javascript">[/CODE] suggests to me that you might be in the wrong forum with this. javascript != java | |
Re: It's doing exactly what you asked for. You didn't ask for what you wanted, though. [CODE] System.out.printf( "::: ",number );[/CODE] The format string here doesn't reference a variable, so it doesn't use number for anything. Try [CODE] System.out.printf( "%d ",number );[/CODE] You might try [CODE] System.out.printf( "%d \n",number );[/CODE] if … | |
Re: What do you mean by "saving nodes"... do you want to save the nodes as in the internal representation of the list, or do you want some sort of text representation of each node? That is, is this output for presentation, or is it saving the data to load into … | |
Re: Whenever I see an == or a != comparison involving a float, I figure that's likely to be the problem. If negative values are prohibited, try sentinelValue<0 as your loop condition and see if that does it. | |
Re: I haven't played with that sort of problem before, but could you do something with inheritance? I'm thinking you'd have an abstract SystemPropsLoader, which would subclass a MacPropsLoader and a LinuxPropsLoader and an Atari2600PropsLoader and so forth for any system you wanted to work with. Trouble is, as I think … | |
Re: There's always a design cost to having more subdivisions. Navigation becomes painful if you have a forum for every language, and it becomes harder to keep track of potentially interesting fora, so it seems sensible to make sure that any forum created is actually needed. As Sanjay points out, there's … | |
Re: First thing you need to do is review arrays. Printing even[i] only prints one value: the value stored at index i of the array called "even". If you have values in an array, you have to lop over the array in some fashion to display them. Your method of writing … | |
Re: Problem #1 - you don't want to make a new Scanner each time through the loop. No need. Get rid of that line. Problem # 2 - you want to break on a negative number? In that case, check the value of that sc.nextInt() call, and if it's negative, do … | |
Re: Please cut it out. I don't know why rep would be important to you, but you'll lose some every time I see a post like this. When someone posts a homework assignment and you do it for them, you are helping them cheat. You are also cheating them of an … | |
Re: Iterative approach? You mean as opposed to recursive? Well, most programming is iterative, in that you walk through a set of values rather than taking an object and repeatedly applying a method to simplify until a base case is reached. So you might iteratively walk through a collection by assigning … | |
Re: (is) (there) (a) (question) (there) (?) (or ((are practicingp) lisp) you)) | |
Re: I'm not sure what you're asking. Do you want to write code that reads a source file? | |
Re: @monarchmk - Much better this way. Now you just need to break it down to "here's where you find the information you need" and you'll be doing great. @Dee1004 - you'll find the information you need in the documentation for the [URL="http://download.oracle.com/javase/6/docs/api/java/io/File.html"]File[/URL] class and in the [URL="http://download.oracle.com/javase/tutorial/essential/io/"]file i/o tutorial[/URL] on … | |
Re: What you are missing, my boy, is the point of the whole exercise. The point is to help people learn. Every problem, every misunderstanding, every "stupid" mistake is a chance to learn something. If you post the solution, soup to nuts, you deprive someone of a chance to learn from … | |
Re: Well, it's pretty simple. You know the main method that you need to have if you're going to kick off from a class? You haven't got one. Probably you want to run this as an applet - try the appletviewer. You'll want to make a toy html page to enclose … | |
Re: More explicitly, an algorithm is a comprehensive, language-independent description of a procedure for solving a problem, in a finite time. I think that about covers it. You might want to read what [URL="http://en.wikipedia.org/wiki/Algorithm"]wikipedia [/URL]has to say about it, for a bit more detail. Or, if you're feeling really ambitious, you … | |
Re: Loops work very well with arrays. If you're having trouble, I don't see where it is in a quick scan through your code. Maybe you can be more specific about what functionality is giving you trouble, or even point us to a particular method? |
The End.