713 Posted Topics
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: I see nothing wrong with this code, assuming the student's names are in integer format. What do you think, 78 111 114 109? | |
Re: 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 … | |
Re: No, what I just posted was not right. Looking again. | |
Re: 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? | |
Re: 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 … | |
Re: 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 … | |
Re: 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? | |
Re: 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 … ![]() | |
Re: 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. | |
Re: [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 … ![]() | |
Re: 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 … | |
Re: 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 … | |
Re: Stepping back: do you know what a Stack is and what operations it supports? | |
Re: [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. … | |
Re: 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 … | |
Re: What's the problem here? Are you having trouble building the expressions to get these values? y = 1-(pow(x, 4)); etc... | |
Re: 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? | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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? ![]() | |
Re: 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 … | |
Re: 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, … | |
Re: 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; … | |
Re: 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, … | |
Re: 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 … | |
Re: Sounds like a problem with your html. Let's see it. Have you tried the appletviewer? | |
Re: 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. | |
Re: 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 … | |
Re: 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? | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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. | |
Re: 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 … | |
Re: There's a pretty good talk on this from the next HOPE. hattorrents.com has it, it's worth a look. | |
Re: 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 … | |
Re: 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 … | |
Re: Yep. That's code, all right. Was there something you wanted to ask about? | |
Re: 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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … |
The End.