713 Posted Topics

Member Avatar for JKP()

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 …

Member Avatar for JKP()
0
95
Member Avatar for دموعي

That's your assignment. What's your question? I do hope you weren't expecting someone to do your homework for you.

Member Avatar for دموعي
0
101
Member Avatar for hao90

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 …

Member Avatar for hao90
0
114
Member Avatar for jon.kiparsky

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 …

Member Avatar for jon.kiparsky
0
337
Member Avatar for chrisbrandon

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. …

Member Avatar for diafol
0
131
Member Avatar for libathos

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 …

Member Avatar for libathos
0
109
Member Avatar for coding101
Member Avatar for ana12
Member Avatar for Dani
-2
182
Member Avatar for kdmuk10
Member Avatar for eyndyel

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 …

Member Avatar for jon.kiparsky
0
177
Member Avatar for ZEZO2010

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 …

Member Avatar for ZEZO2010
0
97
Member Avatar for Chillin2

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, …

Member Avatar for Chillin2
0
106
Member Avatar for J.Killa

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. :)

Member Avatar for jon.kiparsky
0
174
Member Avatar for rickster11

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 …

Member Avatar for pali185
0
955
Member Avatar for lucdatuv

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 …

Member Avatar for MooGeek
-6
342
Member Avatar for anilopo

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 …

Member Avatar for anilopo
0
82
Member Avatar for ajst

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?

Member Avatar for jon.kiparsky
0
139
Member Avatar for baldwindc

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.

Member Avatar for baldwindc
0
358
Member Avatar for Roy1287

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?

Member Avatar for Roy1287
0
132
Member Avatar for Transcendent

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 } …

Member Avatar for jon.kiparsky
0
130
Member Avatar for doom2100

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 …

Member Avatar for jon.kiparsky
0
285
Member Avatar for help!

You're printing lines, one at a time, starting from the top. What goes in the first row?

Member Avatar for jon.kiparsky
0
131
Member Avatar for ProgrammerAl

[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 …

Member Avatar for ProgrammerAl
0
1K
Member Avatar for jwmollman

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 …

Member Avatar for kikovi
0
185
Member Avatar for Dani

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 …

Member Avatar for peter_budo
3
675
Member Avatar for infinitus

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 …

Member Avatar for jon.kiparsky
0
452
Member Avatar for McCurry0x77

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].

Member Avatar for hanvyj
0
3K
Member Avatar for hamste

Your string formatting is a little off. For printf-style formatting, you want something like %2.2f - two digits separated by a period.

Member Avatar for jon.kiparsky
0
209
Member Avatar for curbster

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 …

Member Avatar for curbster
0
889
Member Avatar for bangor_boy

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.

Member Avatar for jon.kiparsky
0
128
Member Avatar for mikev9359

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 …

Member Avatar for jon.kiparsky
0
175
Member Avatar for daviddoria

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 …

Member Avatar for jon.kiparsky
0
430
Member Avatar for maxamillian

[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.

Member Avatar for jon.kiparsky
0
82
Member Avatar for The Dude

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 …

Member Avatar for cwekeybb2351
0
195
Member Avatar for javaking33

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 …

Member Avatar for jon.kiparsky
0
187
Member Avatar for nexus490

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 ' …

Member Avatar for nexus490
0
113
Member Avatar for chippanfat

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 …

Member Avatar for jon.kiparsky
0
196
Member Avatar for ems11

This is java, we don't have access to the pointers. :) What are the problems you need a fresh pair of eyes for?

Member Avatar for jon.kiparsky
0
130
Member Avatar for DallasFan3

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.

Member Avatar for jon.kiparsky
0
617
Member Avatar for acer07
Re: Dani

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.

Member Avatar for ~s.o.s~
-3
126
Member Avatar for adityagarwal

[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 …

Member Avatar for jon.kiparsky
0
504
Member Avatar for javeria3

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 …

Member Avatar for jon.kiparsky
0
3K
Member Avatar for Doshag

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 …

Member Avatar for Doshag
0
177
Member Avatar for pavank75

[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: …

Member Avatar for jon.kiparsky
0
194
Member Avatar for BLUEC0RE

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 …

Member Avatar for BLUEC0RE
0
89
Member Avatar for crisabraham

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]

Member Avatar for jon.kiparsky
0
104
Member Avatar for ChrisXL

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 …

Member Avatar for Gerbiler
0
145
Member Avatar for aquabat

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?

Member Avatar for aquabat
0
5K
Member Avatar for BuhRock

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 …

Member Avatar for coil
0
178
Member Avatar for masamune

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. …

Member Avatar for jon.kiparsky
0
108

The End.