713 Posted Topics

Member Avatar for Dani

[QUOTE=cscgal;1314743]Do you read the DaniWeb news stories? If not ... what about them doesn't interest you?[/QUOTE] I read a few pieces. I hate to be the one to have to say it, but this is not a news-gathering organization and it's not going to be one. The "articles" are sort …

Member Avatar for Ancient Dragon
0
662
Member Avatar for sivaprakashm

Pardon me, I don't know that I understood the question properly. Are you asking what an abstract class is used for in Java?

Member Avatar for jon.kiparsky
0
77
Member Avatar for extemer
Member Avatar for NewOrder

[CODE]for(int i=rowStart;i>rowEnd;i--){ // it should reduce 8 to 7. for(int j=columnStart;j>columnEnd;j--){// it should reduce 3 to 2 while(pieces[i][j]==null){ a++;// here it should count, the number of times a square is equal to null. } [/CODE] If it starts, this while loop will run forever: you do not update the test …

Member Avatar for NewOrder
0
101
Member Avatar for rayden150

[QUOTE]Or simply put the header as: import java.util.*;[/QUOTE] importing java.util.* is seen as bad form in some circles. Generally it's good to make your imports explicit so it's obvious what you're using; this way the import statements are informative to the coder who comes after you. ("I can see you …

Member Avatar for extemer
0
6K
Member Avatar for Cheese Man 808

To insert a % in a printf, you use another % to indicate it's a literal % character: %% So your expression would look like " %%%.3f", aIR); As for the print statement, if you put an [CODE]if (value is out of range) print (error message);[/CODE] at the top of …

Member Avatar for tux4life
0
110
Member Avatar for hehe31

As always, the first step is to break it down into pieces that you can deal with. Break it into logical steps, save the coding for later. Assume that you're a computer, and have only simple arithmetical steps at hand. How would you go about calculating the correct output? (hint: …

Member Avatar for hehe31
0
147
Member Avatar for NewOrder

[QUOTE=NewOrder;1329878]is this a syntax mistake? No, the syntax is fine. The logic is possibly flawed, though. [CODE] if(pieces [a][b]!=null){ array[a][b]=pieces [9-a][b].print(); } [/CODE] wont if filter the nulls out. and leave me with the objects which i will be able to apply my method to? [/QUOTE] No, it won't do …

Member Avatar for NewOrder
0
265
Member Avatar for Duki

[QUOTE] I hate it when people correct me on a stupid mistake that I should've seen myself, so I guess I'm also playing The Game :)[/QUOTE] Paraphrasing Jonathan Swift, I think: "One should never be ashamed to be found in an error, for that only means that you know more …

Member Avatar for ~s.o.s~
0
172
Member Avatar for Stein102

There are a couple of things you could mean here. If you want, you could call this method from Map, and assign the return value to some locally available String. [CODE] someString = RoomType.n(someStringArray);[/CODE] On the other hand, you might mean that you want to run this once and refer …

Member Avatar for coil
0
158
Member Avatar for ezkonekgal

[QUOTE=ezkonekgal;1329488]thanks for the link. its helpful. Maybe we'll just limit the operators that the were gonna include to count. am really confused as to how to count dem. i'm thinking of comparing. Like wen the code reads the file, if it encounters like for example +=, it checks if it, …

Member Avatar for jon.kiparsky
0
661
Member Avatar for Sabryan
Member Avatar for ft3ssgeek

Autocomplete is one of the worst features anyone has come up with - I can't bear machines that try to do my thinking for me. People finishing your sentences, that's bad enough, I won't put up with it from a machine. But I betcha the marching morons will love it …

Member Avatar for MosaicFuneral
0
205
Member Avatar for nikita.chandra

So you've got Eclipse running, but you can't find a "web application" button? Is that the problem?

Member Avatar for Ezzaral
0
80
Member Avatar for extemer

[QUOTE=extemer;1328547] [CODE]class printing{ public static void main(String[] args){ for(int i=1; i<=10; i++) { for(int j=1;j<=5;j++) System.out.print("@"); System.out.print(""); }}[/CODE] [/QUOTE] Is this exactly the code you're running? Did you copy and paste this, or did you re-type it. The easiest way to get this into an infinite loop would be to …

Member Avatar for jon.kiparsky
0
130
Member Avatar for Rick.238

This has got to be a windup. Please tell me there's some surrealist humor that I'm not getting here.

Member Avatar for jon.kiparsky
-4
255
Member Avatar for sushant5252

Of course, you don't know where the tag starts or how long the text is, so [CODE]subString(s.indexOf("<text>")+"<text>".length(), s.indexOf("</text">));[/CODE] would be closer to it. If that's difficult to read, take it apart piece by piece: "<text>" is a string, so it has the String methods, so "<text>".length() returns 6 - why …

Member Avatar for jon.kiparsky
0
102
Member Avatar for comSysStudent

There are other ways of doing it. Since I'm not sure exactly what you're doing, I'm not sure if they're more efficient, but there are always other ways to do anything. If you want it to be locked in to just printing that one string, that one way, probably it's …

Member Avatar for jon.kiparsky
0
191
Member Avatar for Katana24

A good example of the difference between calling a function and reading a variable.

Member Avatar for ~s.o.s~
0
106
Member Avatar for Geekitygeek

I'm pretty new here, but in the last week I've seen far too much of all of the above. The thing that gets me is the "Here, I've written your code for you" posts - completely uncommented, without a hint of an attemt to explain what it is about this …

Member Avatar for Geekitygeek
0
269
Member Avatar for samuel17

Integer division discards remainders and returns the integer result, so for example 5/2 evaluates to 2 - there are two twos in five. Under integer division, x/y means "how many times can I subtract y from x and still get a positive result?" So in your calculation, 10/100 comes out …

Member Avatar for samuel17
0
186
Member Avatar for gudads

There isn't a distinct format specifier for doubles as opposed to floats. The %f is used because C programmers are used to it. Really, it's the right thing: it means "floating-point number goes here", and a double is just a sort of floating-point number - one which uses twice as …

Member Avatar for gudads
0
485
Member Avatar for gudads

Yes, please do ask him about this, and let us know what he says. I don't think it's likely that you can annoy a teacher by showing an interest and trying to learn more. It might be best to pursue it during office hours or after class, because he's probably …

Member Avatar for gudads
0
861
Member Avatar for kazumahits

It looks like you're entering a non-integer value when you run the program. Does it do this when you enter a 1?

Member Avatar for jon.kiparsky
0
11K
Member Avatar for churva_churva

[QUOTE=NormR1;1324790]Many people use an IDE when they make a program, however you can use any text editor to do it.[/QUOTE] Ooh, ooh, can we have the IDE versus editor war? I dibs vi! :)

Member Avatar for jon.kiparsky
0
493
Member Avatar for dbanks4271

When you do this sort of println debugging, you should be testing a hypothesis. Go through the code and try to figure out what each value [B]should be[/B], in your understanding of the code. Start with your line [CODE] number1 = input.nextInt();[/CODE] (ahem, code tags next time, so I have …

Member Avatar for Katana24
0
138
Member Avatar for Sunshineserene

Why do you want to get at the other class's data? Better to let that class tend to its own knitting. The less data you share, the easier your code is to manage. Why is that? Well, if you have a class that depends on data from another class, sooner …

Member Avatar for tong1
0
14K
Member Avatar for ChPravin

[QUOTE]I am using recursion inside a loop. I want to stop the loop as soon as the method is called recursively and resume it again when the call returns[/QUOTE] At first blush, this sounds like a strange thing to want. I'm not sure I really understand what you mean. Do …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for restrictment

Criticizing amateur poetry is too much like shooting ducks in a barrel. Anything I could say about this particular poem would tend to discourage you from writing more, which I don't want to do. So instead, some advice from a non-poet: Thank you for working metrically - non-metrical poetry is …

Member Avatar for diafol
0
150
Member Avatar for xterradaniel

Be careful with your class names and object names. You have MyInteger (a class) and myInt (an occasional object, a formal parameter of certain methods) and sometimes you try to call MyInt.someMethod(), but MyInt doesn't seem to exist. If you're calling a static method, you use the class name, if …

Member Avatar for xterradaniel
0
7K
Member Avatar for ozlem.a17

i is out of scope when you get to the return (line six of your last post) In any case, it would be an int, while getRoom should return a Room (as you correctly specify in the method declaration) I can't tell what sort of thing a RoomReference is, but …

Member Avatar for JamesCherrill
0
116
Member Avatar for kimiko

So the problem is not with your code, but that you can't get a screen shot in Vista? Sorry, can't help you there. Have you tried a Windows forum?

Member Avatar for jon.kiparsky
0
245
Member Avatar for Iamthecheese

Here are some observations to begin with: - You do know, don't you, that there is an ArrayList class available to you already? It's a pretty handy class, you should look it up. (pick your favorite search engine and look for "java arraylist" and the complete description from Sun will …

Member Avatar for NormR1
0
200
Member Avatar for kch1973

How large an array will you need to deal with? If it's a small enough array, you could probably do something simpleminded like go through the original, grab the minimal element, and add it to the new array (easier with ArrayLists, but doable with ordinary arrays). Lather, rinse, repeat. This …

Member Avatar for tong1
0
76
Member Avatar for brettbed

What happens when you go to run it? Is it a logic error (you get a result, but it's not the one you think it should be) or is it a failure to compile (what does the gobbeldygook from the compiler look like?) or a run-time failure (throws an exception …

Member Avatar for jon.kiparsky
0
324
Member Avatar for miraj0072004

Rule of thumb: if masijade says it, it probably works. I'm just sayin', the guy knows his stuff. Second rule of thumb: "it doesn't work" is not a useful error report, and will probably get you nothing useful back. Next time, say what you tried, what you expected to happen, …

Member Avatar for miraj0072004
0
97
Member Avatar for guyfrompluto

Two points, while I find my way to your actual problem - when you're marching up the line of numbers in your isPrime(), you can actually stop when you get to the halfway point, since you know that there is no integer factor of n greater than n/2. - Could …

Member Avatar for guyfrompluto
0
330
Member Avatar for ubi_ct83

"can't support bigger size" - you mean, the array doesn't resize dynamically? The arraylist is one good solution, but you can make a method to increase your array size when it gets too big. That's a pretty simple thing to do. Your method would simply declare a new array of …

Member Avatar for jon.kiparsky
0
112
Member Avatar for authi

First thing, try parsing the input (ipt) as an int. Much friendlier. If I can understand what you want to do, you want to make methods for finding the area of your various shapes and call them in your case statement? Not difficult. Where are you starting from? Do you …

Member Avatar for jon.kiparsky
0
116
Member Avatar for NewAndClueless

Interesting problem. So you've got the first part right - getting the size of the array. Since it's promised to be a square matric, you can accept one parameter as input, that being the length of one side. (4, in this case). So you could generalize this by getting a …

Member Avatar for jon.kiparsky
0
1K
Member Avatar for ozlem.a17

There are three things that could be null in that line that I can see. Those are model, ref1, and the return from getRoom(ref1). Try preceding the line with some test code. Something like [CODE]System.out.println( (model==null)? "Model is null" : model.toString());[/CODE] is a good frame. Put this before the line …

Member Avatar for NormR1
0
142
Member Avatar for Xufyan

You can only return one item from a method - period. However, that item can be a complex object. For example, if you made a method which calculated a location on a graph, you could not return two ints (x,y) but you could (and would) return a Point object, from …

Member Avatar for Xufyan
0
205
Member Avatar for koti86

Try the "file" command. It'll look up the magic number and try to tell you what program created the file.

Member Avatar for jon.kiparsky
0
82
Member Avatar for Sunshineserene

I agree. You don't even need to make a separate program. You can make a method in your current program that opens a file and returns an array. Make a little driver program whose only purpose is to call that method and print out the array. When it looks like …

Member Avatar for NormR1
0
485
Member Avatar for DemiSheep

My advice is to optimize for programmer time, not for run time. A simple change to the program might take you fifteen minutes to an hour. A major change to a serious program might take days or weeks. The time-to-kill of a typical bug depends mostly on how well the …

Member Avatar for jon.kiparsky
0
192
Member Avatar for kimiko

So you want to validate the input, and you have a list of conditions that you're supposed to verify? Easy enough. Why don't you take them one at a time, and make a method to verify each? For example, for your first one, you'd want [CODE]public void everySquareIsFilledIn() { // …

Member Avatar for jon.kiparsky
0
184
Member Avatar for joelogs

Has anyone ever managed to figure out why it is that people feel the need to post solutions to homework problems? It seems quite pointless, especially when it's in a thread that's two years dead....

Member Avatar for jon.kiparsky
0
1K
Member Avatar for Premsathishbe
Member Avatar for ramjeev

Well, it's not such a weird problem. K&R spend most of their time showing ways to rewrite library code, this is a good exercise. We could assume that the input is a String, but then we have to assume some String methods, and then it's just too easy. So let's …

Member Avatar for jon.kiparsky
0
219
Member Avatar for djbhoco

I'd second Norm's advice. Start simple, build up. In the mean time, what was the trouble you were having with rounding? I didn't see it in your code, and searching didn't turn up an instance of "round". Math has a lot of ways to turn floating-point numbers into integers, all …

Member Avatar for jon.kiparsky
0
333

The End.