7,116 Posted Topics
Re: Maybe you would do better with the[ Russion Peasant algorithom](http://mathforum.org/dr.math/faq/faq.peasant.html) - it's basically the same algorithm, but re-arranged so the iterative process and the stopping condition are much more obvious. | |
Re: tarareddy: Many of our members have English as their second or third language, hence the DaniWeb Community Rules: > Do post in full-sentence English > Do not write in all uppercase or use "leet", "txt" or "chatroom" speak ... so less of the text speak please. Anyway, the code you … | |
Re: > I have tried find tutos over internet but I did not find any thats useful Did you look at [this](http://www.lwjgl.org/wiki/index.php?title=Main_Page#Getting_started)? | |
Re: It seems that nobody here understands what you mean by "randomize the array indexs". Java array indexes go from 0 to (length-1) as a strict integer sequence. The language does not allow you to change that in any way, let alone "randomise" it. Can you re-state your requirement in a … | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: Instead of the println method, use printf printf allows you to specify formats for how each variable is printed. Have a look at http://www.homeandlearn.co.uk/java/java_formatted_strings.html | |
Re: There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you. DaniWeb Member Rules (which you agreed to when you signed up) … | |
Re: Yes, mixing nextInt and nextLine is a problem. Unline nextLine, which consumes the new line charater at the end ofthe line, nextInt takes the int and leaves the following new line character in the buffer, so the next readLine reads up to that newline (ie a zero length String). There … | |
Re: Looks more like C to me, definitely not Java. Try the C forum. | |
Re: useroni This was solved 5 years ago. Your answer is too late by approx 4 years 11 months and 3 weeks. | |
Re: Be careful with your terminology. Those are two private *methods*, not *classes*. You didn't post all the code, but my guess is that they're both in the same class. That means they can share any variables that are defined in the class but outside any one method. Move the declaration … | |
Re: Look up the correct syntax for the import statement - you have an extra . that shoudn't be there. | |
Re: You can't just make up your own syntax. Lines 24 and 25 don't correspond to any known Java syntax. It's difficult to guess what you may have intended, so it's hard to suggest a correction. Check out whatever course materials you may have, or Google for relevant material. [This tutorial](http://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html) … | |
Re: What is that post supposed to be? This thread was "solved" 5 years ago. Now you post some code without any explanation. Please spend a minute or two to read the[ DaniWeb Member Rules](http://www.daniweb.com/community/rules) before posting. | |
Re: Nothing in your description or your code has any information about Seats (although the array of Tickets looks like it may correspond to seat positions? Tickets certainly do not come in 12x7 grids!). Maybe you need a Seat class that has, at the very least, an available/ticketed flag. Each flight … | |
Re: Use the appropriate method in the Random class to get a random int 0-5 to represent a roll of a single dice? Or is your question something more than just that? (ps, yes I know it shoud be die) | |
Re: It's a mistake to use doubles here. Decimal fractions (eg 0.1) can't be exactly represented in a binary floating point format, so rounding errors are inevitable. Your values are always an exact integer number of cents, so the obvious simplest (correct) way to hold the values in cents, not dollars, … | |
Re: It's almost impossible to read your code, with unhelpful variables names and no comments, but maybe there's a problem with resetting the "pressed" boolean? The only place you reset it is in the else on 133, but given the obscurity of the code I have absolutely no idea under what … | |
Re: You need to check the syntax for a constructor... | |
Re: Strings in Java are immutable - ie their content never changes. The replace method therefore does not change the original String. It returns a new String that has the replacements made... String somestring="203/9834/345"; String replaced = somestring.replace("/",""); System.out.println(replaced); | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Do some research. If you hit something you don't understand after trying a few searches, come back here with your … | |
![]() | Re: You probably should be looking at something like [Flash](http://en.wikipedia.org/wiki/Adobe_Flash) for this, rather than a full programming language like Java. Fix the links, then try asking this in the web design forum |
Re: `new ImageIcon` is famous for not throwing an exception if it fails, sometimes not even returning a null, just a 0x0 image, so first thing is to check that you really have a valid image after line 3 But why are you doing all this anyway? - just set the … | |
Re: String and StringBuffer have no "extends" relationship, so you can't assign or cast either to the other. Case 1 works because StringBuffer has a constructor that takes a String as parameter. | |
Re: Use JFrame for a normal application window - not a web site - resizable, minimise/maximise/close buttons etc. | |
Re: You are aware that this is the Java forum... ? | |
Re: Yes, that's right. A new array of objects is full of nulls. jalpesh: the required method signatere returns Student[], but it any case you cannot assign nulls to an int, or any other primitive. | |
Re: I have to disagree with javaAddict (yes, dangerous, I know). The Timer class is there so you don't have to build your own bomb-proof threading code. Moreover, if this is part of a Swing application, you should use the swing Timer, not the util one, because that integrates properly with … | |
Re: Rather than just trying different things, add lots of print statements to your code to display the values of all the important variables and arrays wherever they are changed. Then you will be able to see exactly what is happening and where it's going wrong. | |
Re: Thta's just one error, with a complete list of where it came from. In theis case the first two lines tell you everything - on line 48 you try to access an array element [-1] Almost certainly because paint is being called before you select something in "colors", ie selected … | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Post what you have done so far and someone will help you from there. | |
Re: As far as I know the only way would be to get the detailed file formats and write your own parsers using only the classes in the standard Java API - which would be very difficult. | |
Re: There is no one best way, it all depends on your actual requirements. There is lots of info and sample code on the web to help you if you take a moment or two to look for it. DaniWeb Member Rules (which you agreed to when you signed up) include: … | |
Re: It's rubbish coding by someone who hasn't heard of boolean variables. Replace it by a boolean called numberHasADivisor, initially false, set true on line 9, and all should become obvious. | |
Re: Those methods are inherited from the Applet class, so you can call them if your class extends JApplet or Applet, but your Background class doesn't do that. | |
Re: Make the current JFrame invisible (or call its dispose method if you won't need it again) then create a new instance of the next JFrame. | |
Like me you may be curious about the "closures" or "lambda expressions" that were supposed to be in Java 7 and are now the centre-piece of Java 8 (due next year). Also like me you may have Googled for some info, and discovered a smattering of technical articles explaining the … | |
Re: Why not make use of the proven code in the Java API to do the work for you? The `Rectangle` class has an `intersects(Rectangle other)` method. It's trivial to update your main/enemy classes witha method to return the onbjects' bounding rectangle - `new Rectangle(x,y,width,height)` - then you can use the … | |
Re: You'll need to be a lot more specific about your question. What scores? Why an array? What method? etc. ps1: variable names user1, user2, user3 etc make it very hard to understand your code, compared to (eg) q1answer, q1confirm, q1secondTry etc ps2: You do a lot of comparisons to cope … | |
Re: If you know the answer then please ask your actual question. Are you having trouble understanding `finally` blocks? We don't have time to waste playing games. | |
Re: Sorry, but that code makes no sense at all, it just looks like a random collection of assignments. Line 8 will screw up the loop variable, and where did 12 ever come into this problem? I guess you just tried things at random until the output was nearly right for … | |
Re: The Swing equivalent to the old CheckBoxGroup (only one can be selected at any time) is to use *JRadioButton* buttons in a *ButtonGroup* | |
Re: You fix it by looking at the [API documentation for JList](http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html) and using method names that are documented there. You didn't post the error messages like you should, but each of those 3 lines tries to call a method that doesn't exist for JList. You can't just guess or make … | |
Re: Swing was built on top of AWT, so there are a few AWT classes that you still use with swing because there was no need to replace them. Container is one that you still use; your code is OK. | |
Re: What is not the implementation of what? That post makes little sense. Have you tried printing csi immediately after the Naming.lookup? You say it's null, but the API documentation says lookup will throw various Execptions rather than just return null if there is a problem. | |
Re: The answer to your first two questions is "no problem, that's perfectly OK" The output you get is what you asked for on lines 82/83. When you print the order object o1 Java has no information on how to print that, so you get a default printout which shows the … | |
Re: Lines 115-117: catch(Exception e) { } How many times have we said this in the Java forum... Never NEVER *NEVER* do this when writing new code. If/when there is an error you just told Java that you didn't want to know anything about it, and please discard the detailed error … |
The End.