713 Posted Topics
Re: Nice to know that you're willing to help. What sorts of things do you want to do? What sort of thing would you like working on, and what sorts of skills do you have now? What sorts of skills do you want to develop? There's probably some open-source project out … | |
Re: That's your assignment. What's your question? I do hope you weren't expecting someone to do your homework for you. | |
Re: Depends where you're getting the numbers that you're reversing. Easiest thing to demonstrate that your reverse works would be to declare an int array, print it, then print the result of reverse() applied to that array. If you want user input, you can get it from the command line, from … | |
Has anyone got any clever tricks for determining the size of the contents of a directory without doing the obvious (descend recursively and count bytes)? I'm trying to make a progress bar happen for a recursive descend-read-and-load of a directory, and it would be cool if I could track it … | |
Re: If you're not sure of your answer, by all means suggest it but I have two requests: Try to check yourself - someone the other day asserted on the Java forum that you can't call a class's main() method, which is patently untrue and would have been easy to check. … ![]() | |
Re: Not much to go on. What sort of input file are you reading? Text? Source code? CSV? XML? Something else? Where are you stuck? Do you know how to open and read the file? If not, try google, there's a lot to help you there. Then you have to read … | |
| |
| |
Re: What sorts of things have you done already? | |
Re: Awesome! Eyndyel has been waiting TWO YEARS for someont to post that code. Thanks! Seriously - what was the point of posting this, aside from showing off that you know how to sort Strings? (Hint: if that's what you've got to brag about, you might want to keep your head … | |
Re: Cheap and dirty rounding trick: add 0.5 and convert to int. Fails for negative numbers, of course. Think about what you'd do to make it work for negatives as well - and then go ahead and use the library method. (It's always a good idea to use a library method … | |
Re: What your instructor means is that here: [CODE] class Inventory { static Camera[] inventory; public Inventory() { inventory = new Camera[0]; }[/CODE] you declare the array "inventory" to have zero members. That is, it's an empty set: it's an array of no cameras. Since an array's size cannot be changed, … | |
Re: If the course name is the last thing on the file, then nextline() will do you nicely. If it weren't you'd have to look for some clever trick for recognizing the end of the course name - but luckily, it looks like someone's made it easy for you. :) | |
Re: You'll be more likely to get useful help if you start a new thread, this one is six months old and your post has nothing to do with the knight's tour problem. You'll be even more likely to get useful help if you put in some effort instead of just … | |
Re: It seems to me that if you're getting caught and labeled as "disobedient" then it might be you're not as smart as you want to think you are. Surely the first step in breaking a law is to not get caught, no? Yes, there is such a thing as civil … | |
Re: If I understand your question right - not sure I do - the simple assignment should work. What you should bear in mind is that when you retrieve an A from that array, you won't be able to use any but A methods unless you then cast it back to … | |
Re: Yes, that would be an idea. If you mean what I think you mean, it would be a good idea. Why don't you try it and see? | |
Re: You could use an ArrayList. Your addFlight method would then create a Flight object with their data and add it to the list, and you're sorted. EDIT: sorted as in "you're all set", not as in your data is now in order. | |
Re: If you pass the array as a parameter, you can check its length in the method. [ICODE]score.length[/ICODE] will give you what you need. Note that this is a field, not a method. Out of curiousity, do you ever give "i" a value in your actual code? | |
Re: If you want to call a method of a class, you instantiate that class and call the method. [CODE] public class FLTRunner { public class FLTRunner { public static void main(String[] args) { ForLoopTest flt = new ForLoopTest(); flt.main(null); //null because main requires a String array as an argument } … | |
Re: Jeff - pick one of those problems that you'd like to work on, and give us some idea of how you'd start approaching it. It's usually best to break a problem down into simple steps. For example, the first one: [QUOTE]If x is even and y is odd then print … | |
Re: You're printing lines, one at a time, starting from the top. What goes in the first row? | |
Re: [CODE]setLayout(new GridLayout(8,8)); //!PROBLEM! The Gridlayout just doesn't layout the buttons the way I want to // the way i want it to look is 8 rows 4 columns [/CODE] Surely GridLayout(8,8) returns 8 rows, 8 columns? Unless you're skipping some columns, this might be your problem. Maybe this is in … | |
Re: A for loop is a specialized sort of while loop, with a little syntactic sugar on it. You can pretty much always rewrite the one as the other. A do...while() is a little different, in that it executes once before it evaluates the test condition. This can be useful. Like … | |
Re: To me the reputation/points/ranking are all sort of irrelevant. My girlfriend is amused when I tell her I've leveled up, so that's okay, but really, I answer questions that I know how to answer and I occasionally join in a discussion when I'm stymied on some real work. I don't … | |
Re: Unless I'm missing something, there's an easier to do it. (I've got a cold today, so I might have missed something) Make an array grades[0..maxgrade]. As you get a score, increment grades[score]. Now you have data organized so you can use it. Simplest way (conceptually) to use it is: iterate … | |
Re: Sounds like you might want to go back and not sleep through class next time. In the meantime, try [URL="http://lmgtfy.com/?q=java+inheritance+howto"]this link[/URL]. | |
Re: Your string formatting is a little off. For printf-style formatting, you want something like %2.2f - two digits separated by a period. | |
Re: Briefly, there are three types of variables to keep track of, and they are static, instance, and local. Static variables belong to a class: each has one value for all members of that class, and all members of that class have read and write access to them. If they have … | |
Re: Not to carp or anything, but searching on "java write to file" produced 4 million results in bing and 44 million in google. The first page results on both included the information that would have led you to this answer or one very like it. | |
Re: I'd suggest you post this in a new thread rather than bouncing up an only slightly-related one from two years ago. When you do that, you might want to me a little more specific about what you want to do, and show us what you've tried and what's not working … | |
Re: I agree with the above post pointing out that there's a lack of accessible explanations - the new user doesn't necessarily know what you mean when you say "please use code tags". If I were able to provide a link to the "what are code tags" page, I'd use it … | |
Re: [CODE]for (star=1; star <= bottom; star++); {[/CODE] Remove the semicolon in this line. Right now your loop is an empty instruction, repeated [ICODE]bottom[/ICODE] times, followed by a single println. | |
Re: For some reason, the movie "The Day After" came to mind when I read the original post. I was about thirteen when it showed on TV and it just freaked me right the hell out. I think I was probably in the last round of kids that felt a real … | |
Re: You can't store a String as an int, unless it can be parsed to an int. You can expressly cast a double to an int, but you'll lose the fractional part. Furthermore, declaring an array to have five members means you can only store five values in it - there's … | |
Re: That could work. Why don't you try it and see? It's also possible to do it without the array, for example by printing a row at a time: for each column (a range in your example) you'd print a '*' if there needs to be something there, and a ' … | |
Re: If you want to do it with the math library, I would try using math.floor() - look it up in the documentation for java.math. That'll get you the int part, and you can easily get the fractional part from there. Or you could remove the fractional part by casting the … | |
Re: This is java, we don't have access to the pointers. :) What are the problems you need a fresh pair of eyes for? | |
Re: You have a while loop starting at line 30 that gets input from the file. Add each to your array as you read it. You might want to declare your array at the top of the class, since as you have it now it doesn't exist when you need it. | |
Re: Add one for creepy from me. If you don't get it, maybe you should park the laptop for a few months and spend some time in the world, interacting with real people. | |
Re: [CODE]Hangman obj = new Hangman();[/CODE] This is a method of the class Hangman? This line makes a new Hangman object, with its own set of data, so it's starting from zero each time you call "takeGuess". That's your main issue here. I think what you're trying to do when you … | |
Re: You're taking the telephone number as a double, which means it's treating it as a double-precision floating-point number. Since you're not planning on doing any math with the phone number, I'd suggest you store it as a String instead. That'll also give you the option of accepting it as a … | |
Re: I'm not sure I'm understanding the question fully. Is the "user" in this case the consumer of a piece of library code or a luser at the terminal running some program you've written. That is, is the user's input a piece of code running a method, or some text entered … | |
Re: [QUOTE]pls... can any one help me [/QUOTE] Yes. Start by reading the sticky threads at the top of this page. If you haven't found the link to and finished reading the Eric Raymond piece on "Asking Questions the Smart Way", you haven't finished yet. Once you've read that, try again: … | |
Re: Have you read Sun's tutorials on using layout managers? Do that. Sounds to me like you want a GridLayout, but I could be wrong. Layout is an ugly business - there's a lot of "just 'cause I say so" stuff in it - but you can figure it out if … | |
Re: What happens in this loop? How often does it happen? [CODE]while(num > 0){ test.setText("bla"); for(int i=0;i<6;i++){ b[i] = Integer.parseInt(String.valueOf(s.charAt(i))); }[/CODE] | |
Re: It sounds like you're asking for help on how to approach a problem of this sort - good man, that's the right sort of question to ask. My usual advice for this sort of thing is to start by trying to perform the task on paper, and to come up … | |
Re: Is this a tree like in a data structure, like a binary tree or a red/black tree, or are we talking about the Swing class JTree, or what are we talking about? | |
Re: Easiest way to do what you're trying to do would be to make a for loop from str.length()-1 down to 0. Take the least-significant characters first, multiply them the appropriate power of ten, and add them into an int. So for your "1234" example, you'd take charAt(str.length()-1) on the first … ![]() | |
Re: These are nice puzzles to solve. I would start by writing "stubs" for each of the methods you'll have to write - a "stub" is a placeholder method, which returns an answer known to be wrong. This gives you a starting point: you have something that will compile and run. … |
The End.