713 Posted Topics

Member Avatar for mrnutty

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?

Member Avatar for susheelsundar
2
284
Member Avatar for kris0r

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 …

Member Avatar for jon.kiparsky
0
81
Member Avatar for terexberd

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

Member Avatar for jon.kiparsky
0
141
Member Avatar for Alpdog14

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.

Member Avatar for JamesCherrill
0
183
Member Avatar for penguino138

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

Member Avatar for penguino138
0
520
Member Avatar for MrHardRock

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

Member Avatar for JamesCherrill
0
241
Member Avatar for terexberd

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]

Member Avatar for terexberd
0
213
Member Avatar for joeyxaza

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

Member Avatar for jon.kiparsky
0
124
Member Avatar for MisterSinyster

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?

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

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 …

Member Avatar for sourabh17
0
152
Member Avatar for megsilm

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 …

Member Avatar for jon.kiparsky
0
285
Member Avatar for sariberri

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

Member Avatar for sariberri
0
218
Member Avatar for royng

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

Member Avatar for royng
0
167
Member Avatar for frogboy77

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 …

Member Avatar for jon.kiparsky
0
269
Member Avatar for stupidbumbum

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?

Member Avatar for jon.kiparsky
0
91
Member Avatar for jon.kiparsky

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 …

Member Avatar for jwenting
2
269
Member Avatar for sam.udo

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

Member Avatar for sam.udo
0
115
Member Avatar for iwannalearn

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 …

Member Avatar for lisaroy1
0
156
Member Avatar for frogboy77

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 …

Member Avatar for frogboy77
0
159
Member Avatar for xxmp

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 …

Member Avatar for JamesCherrill
0
116
Member Avatar for grabit

Try the [URL="http://www.daniweb.com/web-development/javascript-dhtml-ajax/117"]javascript[/URL] forum, they might have better answers there.

Member Avatar for jon.kiparsky
0
107
Member Avatar for anumash

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

Member Avatar for sam.udo
0
150
Member Avatar for Mkmd13

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

Member Avatar for Mkmd13
0
473
Member Avatar for singuland
Member Avatar for singuland
0
87
Member Avatar for WolfShield

conv is a static method. It doesn't have a "this" - it executes without an object.

Member Avatar for WolfShield
0
158
Member Avatar for jfountai

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

Member Avatar for jon.kiparsky
0
647
Member Avatar for Cool_Tori

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 …

Member Avatar for jon.kiparsky
0
137
Member Avatar for gedas

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 …

Member Avatar for mKorbel
0
208
Member Avatar for SCass2010

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 …

Member Avatar for jon.kiparsky
0
2K
Member Avatar for kay19

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 …

Member Avatar for kay19
0
453
Member Avatar for TrustyTony

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)

Member Avatar for Dani
0
227
Member Avatar for sciprog1

Can you post the compiler output? It'd help if I could see what errors I'm looking for.

Member Avatar for sciprog1
0
224
Member Avatar for Jessurider

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 …

Member Avatar for sourabh17
0
422
Member Avatar for m610

This line here [CODE]<script language="javascript">[/CODE] suggests to me that you might be in the wrong forum with this. javascript != java

Member Avatar for masijade
0
380
Member Avatar for newack

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 …

Member Avatar for newack
0
404
Member Avatar for hauda67

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 …

Member Avatar for jon.kiparsky
0
143
Member Avatar for Tarkenfire

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.

Member Avatar for Tarkenfire
0
186
Member Avatar for Japus

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 …

Member Avatar for mKorbel
0
260
Member Avatar for Seattle Slim

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 …

Member Avatar for jon.kiparsky
2
392
Member Avatar for MrHardRock

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 …

Member Avatar for MrHardRock
0
152
Member Avatar for newbieha
Re: loop

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 …

Member Avatar for newbieha
0
111
Member Avatar for desert564

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 …

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

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 …

Member Avatar for jon.kiparsky
0
90
Member Avatar for code07

(is) (there) (a) (question) (there) (?) (or ((are practicingp) lisp) you))

Member Avatar for Taywin
0
94
Member Avatar for sanam_1

I'm not sure what you're asking. Do you want to write code that reads a source file?

Member Avatar for jon.kiparsky
0
64
Member Avatar for Dee1004

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

Member Avatar for mKorbel
0
219
Member Avatar for caut_baia

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 …

Member Avatar for caut_baia
0
370
Member Avatar for Matulin

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 …

Member Avatar for jon.kiparsky
0
460
Member Avatar for omer.chaudhary

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 …

Member Avatar for jon.kiparsky
-1
262
Member Avatar for elite01

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?

Member Avatar for jon.kiparsky
0
530

The End.