7,116 Posted Topics

Member Avatar for sobias

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.

Member Avatar for sobias
0
1K
Member Avatar for tarareddy

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 …

Member Avatar for tarareddy
-1
7K
Member Avatar for Viped

> 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)?

Member Avatar for ~s.o.s~
0
440
Member Avatar for Monkey101

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 …

Member Avatar for Nutster
0
90
Member Avatar for Rasheed1988

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.

Member Avatar for JamesCherrill
0
159
Member Avatar for UNDER-18 FG

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

Member Avatar for UNDER-18 FG
0
321
Member Avatar for mark.cueva1

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

Member Avatar for jalpesh_007
-1
172
Member Avatar for somjit{}

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 …

Member Avatar for somjit{}
0
261
Member Avatar for kmachstang
Member Avatar for kmachstang
0
117
Member Avatar for kimbokasteniv

useroni This was solved 5 years ago. Your answer is too late by approx 4 years 11 months and 3 weeks.

Member Avatar for JamesCherrill
0
7K
Member Avatar for psy.blast

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 …

Member Avatar for JamesCherrill
0
211
Member Avatar for UNDER-18 FG

Look up the correct syntax for the import statement - you have an extra . that shoudn't be there.

Member Avatar for Lucaci Andrew
0
309
Member Avatar for foofdude

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

Member Avatar for JamesCherrill
0
448
Member Avatar for Dio1080

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.

Member Avatar for JamesCherrill
0
185
Member Avatar for rami sohaill

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 …

Member Avatar for JamesCherrill
0
341
Member Avatar for primeru333

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)

Member Avatar for JamesCherrill
0
562
Member Avatar for Yoink

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

Member Avatar for Yoink
0
529
Member Avatar for Kronolynx

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 …

Member Avatar for JamesCherrill
0
261
Member Avatar for mcmanuel20
Member Avatar for greg2186
Member Avatar for pattmorter
Member Avatar for riahc3

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);

Member Avatar for riahc3
0
143
Member Avatar for rssk

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 …

Member Avatar for stultuske
0
2K
Member Avatar for viv941

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

Member Avatar for JamesCherrill
0
179
Member Avatar for easyscript

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

Member Avatar for mKorbel
0
829
Member Avatar for rahul.ch

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.

Member Avatar for rahul.ch
0
200
Member Avatar for rssk
Member Avatar for hwoarang69

Use JFrame for a normal application window - not a web site - resizable, minimise/maximise/close buttons etc.

Member Avatar for jalpesh_007
0
192
Member Avatar for deadsolo
Member Avatar for MegaBigBigYo

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.

Member Avatar for MegaBigBigYo
0
191
Member Avatar for cmh0114

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 …

Member Avatar for JamesCherrill
0
854
Member Avatar for somjit{}

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.

Member Avatar for JamesCherrill
0
241
Member Avatar for Kronolynx

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 …

Member Avatar for Kronolynx
0
270
Member Avatar for gourav_rao

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.

Member Avatar for JamesCherrill
0
84
Member Avatar for Shanti C

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.

Member Avatar for stultuske
0
339
Member Avatar for agca

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

Member Avatar for JamesCherrill
-2
185
Member Avatar for engrjawad
Re: Flag

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.

Member Avatar for jalpesh_007
0
185
Member Avatar for hwoarang69

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.

Member Avatar for JamesCherrill
0
114
Member Avatar for lo0lo0999

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.

Member Avatar for mKorbel
0
217
Member Avatar for JamesCherrill

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 …

Member Avatar for JamesCherrill
0
170
Member Avatar for hwoarang69

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 …

Member Avatar for JamesCherrill
0
318
Member Avatar for Amiro

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 …

Member Avatar for JamesCherrill
0
226
Member Avatar for forjustincase

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.

Member Avatar for JamesCherrill
0
96
Member Avatar for forjustincase

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 …

Member Avatar for JamesCherrill
0
262
Member Avatar for hwoarang69

The Swing equivalent to the old CheckBoxGroup (only one can be selected at any time) is to use *JRadioButton* buttons in a *ButtonGroup*

Member Avatar for hwoarang69
0
241
Member Avatar for hwoarang69

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 …

Member Avatar for JamesCherrill
0
166
Member Avatar for hwoarang69

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.

Member Avatar for hwoarang69
0
239
Member Avatar for coroll

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.

Member Avatar for JamesCherrill
0
289
Member Avatar for omgnametaken

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 …

Member Avatar for omgnametaken
0
113
Member Avatar for soumyadityac

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 …

Member Avatar for JamesCherrill
0
146

The End.