713 Posted Topics

Member Avatar for nur_ahm4d

There are several ways to do this. Some of them are part of the String class - see the [URL="http://cupi2.uniandes.edu.co/site/images/recursos/javadoc/j2se/1.5.0/docs/api/java/lang/String.html"]Sun website[/URL] for those. If you want to do it by hand, we can walk you through the way you'd go about it.

Member Avatar for jon.kiparsky
0
242
Member Avatar for Xeros606

Don't worry so much about knowing the names of different technologies. If I were to ask you to write a program, would you panic? Or would you feel like you knew how to start figuring out what you needed to write? For me, the most important skill in being a …

Member Avatar for jon.kiparsky
0
109
Member Avatar for Megha SR

[QUOTE=JamesCherrill;1317537] You want to do a switch on Strings? Don't we all. You can't. It may be introduced in Java 1.7. [/QUOTE] I don't. If you're trying to switch on Strings, to my mind that suggests that you've got something confused somewhere in your program. Here's my reasoning: The only …

Member Avatar for jon.kiparsky
0
125
Member Avatar for rayden150

Without even reading the code, I'm going to say yes, you can. I may be wrong, but generally it's possible to bolt a Swing GUI onto most things. What do you want the GUI to do? The design part is your job, though you might get some suggestions from the …

Member Avatar for tong1
0
191
Member Avatar for churva_churva

I see nothing wrong with this code, assuming the student's names are in integer format. What do you think, 78 111 114 109?

Member Avatar for VernonDozier
-1
130
Member Avatar for tinamary

There is actually a significant difference between the abstract class and the interface. The abstract class depends on inheritance, while there is no inheritance in implementing an interface. An interface simply says "I can do these things". It is a promise to the compiler that a method that implements this …

Member Avatar for jon.kiparsky
0
155
Member Avatar for Yaserk88
Member Avatar for NewOrder
Member Avatar for P00dle

Just a guess, but do you actually call aregex() in there somewhere? If not, your strRegex is going to be "" when you're calling accept(). Also, you don't use the parameter "dir" in accept() - could this be part of your problem?

Member Avatar for P00dle
0
135
Member Avatar for fringe

Or, if you want to allow for multiple circles, triangles, or whatnot, you might allow for the input of a parameter or two, to represent the dimensions of the geometrical object in question. For a circle, for example, you need an int or a double, depending on whether you're dealing …

Member Avatar for tong1
0
123
Member Avatar for plasticfood

Okay, so you can't use ifs, that means you have to use integer arithmetic. Think of it this way: if you need to give $1.52 in quarters, dimes, nickels and pennies, one way to do it would be to take .25 at a time out of that sum until there …

Member Avatar for jon.kiparsky
0
150
Member Avatar for hazeeel

I don't see the declaration immediately, but let me guess. One of the dimensions of your array is 3, right? So when you try to index position 3, you walk off the edge. Is that it?

Member Avatar for hazeeel
0
124
Member Avatar for drizzled42

This is a piece of code that, were you to write it, would demonstrate a reasonable ability in programming. You would have to have your hand in all steps of the development in order to turn this in and not be a liar. Go back to your desk and work …

Member Avatar for coil
0
200
Member Avatar for oochi

Sure. Post the code you've got so far, and don't forget to use the code tags. Dont forget: More specific questions will get you more specific answers.

Member Avatar for NormR1
0
91
Member Avatar for fr0styh3rb

[QUOTE=fr0styh3rb;1313003]Hello, first I must say thank you for the feedback, I made some changes but I still cant get the program to compile. [/QUOTE] It would be helpful if you could include the compiler output, which is telling you why it won't compile. When you type "javac Inventory.java", what do …

Member Avatar for coil
0
418
Member Avatar for rebellion346

You're getting good advice on your logic from Norm, I have nothing to add there. A matter of style that might help you out, though, is to replace the constant "1000000" in your loop with a final variable, declared like this private final NUMBER_OF_TIMES_TO_ROLL = 1000000; or some similarly expressive …

Member Avatar for rebellion346
0
494
Member Avatar for lisa.wells7

If I can cut in... (sorry!) ... I'm not quite clear on the organization here. What class is createCouple() a method of? I don't see where you have dancersList as a variable, and gender is a field of Dancer. Regardless of where it goes, I'm assuming there's more that's needed …

Member Avatar for lisa.wells7
0
207
Member Avatar for idontknow19

Stepping back: do you know what a Stack is and what operations it supports?

Member Avatar for jon.kiparsky
0
129
Member Avatar for jemz

[QUOTE=Megha SR;1313435]eg= String s="Hai! Hello Java";//this is the input or sentence whose words are to be counted [COLOR="Red"]int[/COLOR] i,words=1;//variable words is used to count the number of words. [COLOR="red"]char[/COLOR] c;//variable c is used to extract each character. for(i=0;i<s.length();i++) { c=s.charAt(i); if(c==' ')//space is counted to determine the number of words. …

Member Avatar for jon.kiparsky
0
125
Member Avatar for BboyRodimus

Coil is right. If you use a while (true) you need to get out of the loop by some means. There are two graceful ways. One would be to break on some condition, the other would be to return from the method you're in. Ungraceful ways include System.exit() or throwing …

Member Avatar for jon.kiparsky
0
111
Member Avatar for DeIntegro

What's the problem here? Are you having trouble building the expressions to get these values? y = 1-(pow(x, 4)); etc...

Member Avatar for DeIntegro
0
178
Member Avatar for ashwinpdy

This question is far too vague to get any useful help. What sort of help are you looking for? What "platform" are you trying of offer as a service? What have you done so far? What sort of design decisions have you made that we should know about?

Member Avatar for jon.kiparsky
0
110
Member Avatar for cac186

1) you're returning an empty string. Not null, but a String of length 0: "" 2) you're not reading the String returned by your method. It looks like you want the String to be the path to the file, and to use that as an argument to your f.getPath(), is …

Member Avatar for cac186
0
146
Member Avatar for monu952

Maybe you should come up with something to deal with scheduling and time usage. It might help to prevent spending 40% of the project's time budget on picking the project.

Member Avatar for monu952
-1
144
Member Avatar for Roodra

Just out of curiosity, did anyone mention the word "ethics" or "responsibility" when they gave you this assignment? I only ask because it seems an odd sort of assignment to give to someone who obviously doesn't actually know the language yet, and I'm wondering what other areas have been skipped …

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

[CODE] return myArray; // Used to check to see if the method places the tokens into the array correctly // printArray(myArray);[/CODE] This is not just a check; the return value is the only result of the method. myArray is a local variable - when you return from the method that …

Member Avatar for tong1
0
1K
Member Avatar for gibson.nathan

Okay, let's back up to requirements and walk through a little design process. Might be a good thread for beginners to follow. Nathan - who are the users of this program, and what are they wanting to do with it? What information is each of them concerned with?

Member Avatar for coil
0
676
Member Avatar for aditya027

This is much easier to read. (I'm actually glad that you didn't include debug code here, although I agree with Norm that they will certainly help you know what's going on at any given point in your code.) I'm reading it now, notes follow: - why no constructor for your …

Member Avatar for NormR1
0
119
Member Avatar for Mylsamy

You've got two questions here. I'm not an expert in this area, but I'll take a stab at it. You should certainly do your own research before you take my word for it, though. First question is, how can I tell whether a send worked. As far as I know, …

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

It would help if you had three places to put the values. Better still would be if you put the values into the ArrayList as a block of three. If a unit of data consists of three values, make it an object: [CODE] public class DataObject { private Point p1; …

Member Avatar for jemimaloh
0
135
Member Avatar for jiraiya

The first thing that came to my mind was to pass messages back and forth between the objects. Suppose you have a Cannon, a FireControlOfficer, and a Gunner. The FireControlOfficer wants to just say "Fire when ready", but there's interaction - the gunner can't just say "Cannon, aim yourself", "Cannon, …

Member Avatar for JamesCherrill
0
148
Member Avatar for aditya027

That's a bunch of problems and a lot of unformatted code (use code tags next time!). Let's take one at a time. [QUOTE]Hi..In this game m trying to make the ball bounce inside the circles and move in random direction.Not able to do so.[/QUOTE] What is it you're not able …

Member Avatar for aditya027
0
465
Member Avatar for musikluver4
Member Avatar for Megha SR

Your "square" method has void as its return type, but you're trying to read a returned value from it. Set the return type to "int" (since you're only acepting integer input parameters) and return the value of area3, and it should be fine.

Member Avatar for NormR1
0
76
Member Avatar for bunifrog

When you "break" out of a block, you can't return to that point in the code, you can only start from the beginning. Breaking up the method into its functional units is the best solution. Ideally, you want each method to do one thing. Rather than putting the input in …

Member Avatar for jon.kiparsky
0
320
Member Avatar for gavalipm

Write a sonnet generator. Able to come up with a sonnet on a given subject, and explain why it's good. That mega enough for you?

Member Avatar for jon.kiparsky
-4
75
Member Avatar for P00dle

There have been a few threads on static vs. instance methods and fields recently. You might find those worth a look. Very important underlying ideas, if you don't understand static and instance you're going to have a lot of trouble.

Member Avatar for jon.kiparsky
0
567
Member Avatar for tedtdu

Why are you peeking at the stack in the first place? Think of it as a real stack: push and pop only. When your current token has a '/', you pop the stack. If the item you pop is not equal to the current token (modulo '/', of course) then …

Member Avatar for jon.kiparsky
0
283
Member Avatar for tedtdu

I can't think of a good way to do this with built-in string methods. You might have to write a little scanner method to do this. It's actually not hard, but you have to think it through before you start writing it. What you'll be doing is writing a little …

Member Avatar for JamesCherrill
0
126
Member Avatar for flowin

[QUOTE] I am using return type String on the method, but I don't want to output to the command window.[/QUOTE] Return a String, you can do whatever you want with it when you get it: print it to the console, stick it in a TextArea, parse it for XML, hash …

Member Avatar for javaAddict
0
88
Member Avatar for Agent Cosmic

The best way to learn is by writing. Any good intro comp sci book - doesn't have to be a Java-focussed one! - will have a slew of good problems to play with. Work through a bunch of those, and you'll be well underway.

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

Paging Douglas Hofstadter... (sorry) This is a C-type trick. Read it in pieces. While something isn't equal to -1, do the body of this loop. What's being compared to -1? it's (i=cis.read(cipherTextBytes)) Okay, that's an assignment to i. The cis object is being asked for a read on "cipherTextBytes", and …

Member Avatar for JamesCherrill
0
119
Member Avatar for slfisher

There's a pretty good talk on this from the next HOPE. hattorrents.com has it, it's worth a look.

Member Avatar for slfisher
1
467
Member Avatar for zandiago

This is argument is always good for some confusion - people like to flip back and forth between legal arguments and moral arguments, and when those don't work they like to move over to economics, or even (god help us) sociology and the squidgier sciences. The legal case is pretty …

Member Avatar for jon.kiparsky
2
981
Member Avatar for tedtdu

If you're writing your own parser, first you have to recognize your tokens. Parsing XML, you've pretty much got two sorts of tokens: things in angle brackets, and things not in angle brackets. If you're just validating that tags are matched, then all you need to do is check that …

Member Avatar for NormR1
0
210
Member Avatar for gabz16
Member Avatar for gabz16
0
399
Member Avatar for ciali

I guarantee you this won't compile with the javac. :) As for the code, you may be slipping units on the way in. Are you anticipating input as float or integer? If I get a low B, is my mark input as 80 or .8? From the assignment, I assumed …

Member Avatar for Adak
0
132
Member Avatar for countpuchi

If you're using an array, the enhanced for is a good one for this application, but you should learn the details. It can be confusing. Google "java enhanced for" and you should get a number of explanations to choose from. A standard for loop is well-suited to iterating over an …

Member Avatar for jon.kiparsky
0
198
Member Avatar for vgd

Can we see what you've tried so far? Better still, can you tell us in English how your current solution works? It's very helpful to all concerned if you spell out the details in this fashion. We get a chance to see how you're thinking about the problem, and you …

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

[QUOTE]Masijade, have you ever paused for a second to take stock of your contribution to this forum? Have you realized that you have not contributed any new knowledge in the site from your 2,998 posts apart from riding on peoples’ backs.[/QUOTE] I don't think anybody here really needs this pointed …

Member Avatar for jon.kiparsky
1
526

The End.