7,116 Posted Topics

Member Avatar for sajid_bd007

Line 36 - you want to know if the price is greater than the highest you have found so far (cf line 45). Then look at the initialisation of cheapBookPrice - if it starts at 0 will you ever find a cheaper one in your data?

Member Avatar for JamesCherrill
0
170
Member Avatar for 47pirates

@godzab: Please explain exactly how you think AtomicInteger is relevant here. @47Pirates: All you need is a simple listener that updates the table. Please post your latest/best attempt for further help.

Member Avatar for 47pirates
0
519
Member Avatar for GeekTool

Put the strings into an array and use the randon int (0-3) as the index to retrieve one element of the array.

Member Avatar for GeekTool
0
209
Member Avatar for blackmagic01021

Thank you for sharing that information with us. ps: If you have a question please post an exact description of the problem, with complete copies of any exceptions or error messages, and all the relevant source code. We may be smart, but we're not mind readers!

Member Avatar for JamesCherrill
0
125
Member Avatar for Ritesh_4

The languages are very similar, but the APIs are completely different. Converting the syntax (with a few specific exceptions) is no big deal, but mapping/converting the APIs would be a massive task.

Member Avatar for Ritesh_4
0
403
Member Avatar for s0urce

[QUOTE]Generally a bad design to include so many parameters in the constructor. Getters and setters should be invoked over extensively adding input parameters.[/QUOTE] I can't let this pass without comment. When you instantiate any class there is some number of values that must be set for subsequent uses of that …

Member Avatar for s0urce
0
203
Member Avatar for jonny93

`total = number++;` Probably not what you intended!. This copies number to total, then adds 1 to number. You ned to add number to total.

Member Avatar for delta_frost
0
265
Member Avatar for GeekTool

They have many similarities in how they are used, and a quick Google will find you lots of detailed discussion on the differences, but the shortest version is that abstract classes can contain far more than interfaces (eg actual method defininitions), but you can only `extend` one class at a …

Member Avatar for delta_frost
0
229
Member Avatar for StormHawk

That's not the correct syntax for multiple parameters - every parameter must have its type (String etc) specified explicitly, eg `void add(String a, String b...` With 26 parameters you may want to consider passing an array instead? ps: Next time don't just say "I get an error". Always post the …

Member Avatar for delta_frost
0
315
Member Avatar for Valiantangel

When you code `System.out.println( IntegerSet.union(setA, setB));` the union method returns an instance of IntegerSet, and println then calls that object's `toString()` method to get a printable version of the object. Every object inherits a version of toString from the Object class, but it's not very useful (it just returns the …

Member Avatar for JamesCherrill
0
134
Member Avatar for jwings

paint for a JFrame also paints the borders and the children of the frame. By overriding it and not calling super.paint you have supressed JFrame's painting those objects. If you want to have custom painting the best option is a new subclass of JPanel and override its paintComponent method, thus …

Member Avatar for JamesCherrill
0
643
Member Avatar for MadJako

Welcome. We are happy to help anyone, beginner or expert, as long as they are willing to listen and put in some effort. > might not have been initialized Means what it says. The compiler has worked out the possible routes through ypur program, and seen that one or more …

Member Avatar for MadJako
0
616
Member Avatar for 47pirates

The problem seems to be that the document is locked when the listener is called, so when you try to update the document you can't get the lock to write to it. The solution, if you want to keep it working the same way, is to use SwingUtilities.invokeLater to run …

Member Avatar for JamesCherrill
0
2K
Member Avatar for Valiantangel

The real problem here is not how you are accessing static variables; it's the fact that you are mis-using static in the first place. static means that every instance of that class shares the one same value - in this case there is only one` boolean[] a`, which is shared …

Member Avatar for JamesCherrill
0
370
Member Avatar for GeekTool

`enum Status{WIN, CONTINUE };` That's enough to define and initialise the enum, you don't need anything else. What exactly was the comment that confused you?

Member Avatar for ~s.o.s~
0
3K
Member Avatar for xGiraffe

Put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong. Focus on the code that parses the user's input. Once you can see exacty what values are being set and used at each …

Member Avatar for JamesCherrill
0
434
Member Avatar for SuperManofBC

> How do I put (File soundFile) as the parameters in new Track()? If Track has a constructor that accepts a File as a parameter, then just create a File and pass it, ie File f = .... create the file as needed track = new Track(f); If Track does …

Member Avatar for stultuske
0
648
Member Avatar for rtellez700
Member Avatar for frank85

In your toString method you can include \n characters to start a new line

Member Avatar for JamesCherrill
0
108
Member Avatar for moussa_90

Yes, we can help. Just check out the DaniWeb member rules before you post - in particular ."Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules

Member Avatar for JamesCherrill
0
40
Member Avatar for hyung101

Use the String split method with a comma as the split character to separate the strings into a String array, then use trim() on each string to get rid of leading and/or trailing blanks as required. Or, if you're a regex black-belt you could define the separator string as <any …

Member Avatar for hyung101
0
417
Member Avatar for Valiantangel

Just go back to the problem definition and work through it one step at a time. It's written so as to help you. Start with the array of booleans with index values 0-100 inclusive. (The size is defined in the problem statement, so you don't need it as a parameter.)

Member Avatar for JamesCherrill
0
855
Member Avatar for jwings

Maybe some component in your window has keyboard focus and is consuming the ctrl-X (cut) keystroke?

Member Avatar for JamesCherrill
0
100
Member Avatar for enakta13

A small hint: conversion of char to the int value it represents: We know that char is a numeric type, and we also know that '0' to '9' are consecutive in UniCode, so once you have checked that k is a digit you can safely replace all thise if/elses with …

Member Avatar for stultuske
0
180
Member Avatar for malsmit2014

That is not a compile error, its a runtime error. I simply means what it says - it cannot find that file. The file name may be wrong, or it may be in a directory other than the one where Java is looking for it.

Member Avatar for JamesCherrill
0
188
Member Avatar for kng9

You are probably getting the "not initialised" because your init method is terminating abnormally (with an NPE exception). The NPE means an uninitialised variable. Your line numbers don't seem to match the error message exactly, but at a guess it's probably due to your not initialising yout JPanel variables. The …

Member Avatar for kng9
0
159
Member Avatar for nHulk

Put a load of print statements into your code, printing the values of the key variables at each stage so you can see where it's going wrong.

Member Avatar for NormR1
0
295
Member Avatar for jwings

When you have a controller and a GUI it normally goes like this: The controller is responsible for invoking the GUI, and passes itself as a parameter to the GUI constructor, so the GUI has a reference to the controller. The GUI is responsible for all listeners on the GUI …

Member Avatar for JamesCherrill
0
95
Member Avatar for profyou

Mainstream languages such as Java and C# all have very similar structures and syntax - learn one and the others are no big step. General programming skills such as understanding algorithms, designing and testing code etc etc are also largely language independent. The biggest hurdle in moving from one language …

Member Avatar for jackbauer24
0
288
Member Avatar for rtellez700
Member Avatar for thanatos1

DIY loops and graphics are not the way to go. Swing is in charge of Java GUIs, so you have to operate within swing's design assumptions. Swing Timer is the timer used by Swing itself - you can definitely rely on it. Also its the only one that ensures you …

Member Avatar for JamesCherrill
0
723
Member Avatar for speakon

You have giant arrays of 10,000 elements each, of which only the first 2 elements are populated and the remainder are null. When you loop you loop through the whole array, so you are guaranteed to hit nulls sooner or later. You need a variable that tells you how many …

Member Avatar for speakon
0
389
Member Avatar for newprogrammer12

is userInput supposed to be int or String? - either way this won't work!

Member Avatar for jackbauer24
0
220
Member Avatar for wab9jon

That's what the code on lines 50-55 does right now. What exactly is your question?

Member Avatar for wab9jon
0
213
Member Avatar for Maymac

The code to create a GUI is always a long long list of repetitive add/set method calls - people often use a GUI design tool to generate them. It really doesn't have a structure. The only thing you can do is to put it all in a simple method, eg …

Member Avatar for JamesCherrill
0
116
Member Avatar for Rvjain99

Yes, that's exactly what it looks like. On line 6 you declare rtot,vtot,ptot,gtot,ntot,patot, but then on lines 38, 49, etc you declare new local variables with the same names.

Member Avatar for JamesCherrill
0
221
Member Avatar for velr

@gbulfon Your conrtributions are very welcome here, but please check the dates before adding to an existing thread - this one is 5 months old, so either the OP has found a solution or he doesn't care any more.

Member Avatar for JamesCherrill
0
2K
Member Avatar for _Brooksy

Line 1 is the start of the definition of a method called main. (Every program needs this method - it's the one that is called first when you execute your program). Then on line 3 you start the definition of another method. You can't define one method inside another. You …

Member Avatar for JamesCherrill
0
310
Member Avatar for ausops

Pushparaj ruban This question was answered a year ago. Do you think the OP is still waiting for someone to confirm it?

Member Avatar for JamesCherrill
0
2K
Member Avatar for sammoto

I don't see anything wrong with updating x0 and x1 like you are doing - more variables won't help. But there are two logic problems as far as I can see: 1. Your loop condition will always be true, regardless of what's in the loop. So your loop will always …

Member Avatar for sammoto
0
241
Member Avatar for Cross213

@cross213: stultuske is giving you good advice, so you should make more effort to follow it rather than wasting his time. Your latest code completely fails to implement the perfectly good solution that he gave you earlier. Re-read his posts and think carefully about what he says..

Member Avatar for Cross213
0
305
Member Avatar for sid78669

This is very confusing because the variable names in your code look like the ones in the diagram/formulae, but are used completely differently -eg in the diagram x2,y2 is the centre of the circle, but in your code they are one of the intersection points. So my advice is 1. …

Member Avatar for JamesCherrill
0
2K
Member Avatar for gedas

Are you asking to run a windows executable on Max or Linux? That's not a Java problem - you need a windows emulator or native windows API implementation, so on Mac you need Parallels (or equivalent), on Linux its Wine (or equivalent). Is this a very specific application, or do …

Member Avatar for NormR1
0
96
Member Avatar for Upoma

The client and server will probably be quite different programs, with completely different installation requirements, so I would say "keep them separate". The client will probably just be a single jar file, but the server will be a different jar, plus database etc. Either way, your installer can still ask …

Member Avatar for JamesCherrill
0
806
Member Avatar for Stein102
Member Avatar for subrat_p

You extended JPanel, not JFrame. You can't display a JPanel except inside a top-level container eg JFrame.

Member Avatar for JamesCherrill
0
475
Member Avatar for Fotis_13

Without reading all the code, that certainly looks sensible. Just write a small test to see for yourself if it is right... all you need is a method to print the contents of the tree after you have inserted some data.

Member Avatar for JamesCherrill
0
96
Member Avatar for Majestics

A byte is 8 bits, nothing more. You may chose to interpret that as a number, or as a character, but that's up to you. The simple read() method for input streams places those 8 bits as the least significant 8 bits of an int variable, where you can use …

Member Avatar for Majestics
0
198
Member Avatar for GeekTool

I suspect that's the wrong language! The usual Java version is `System.out.println(...`

Member Avatar for GeekTool
0
111
Member Avatar for whit89

The "programming model" is the design and intention behind the classes and APIs, so if you understand how the classes and methods all fit together to make an application then you have understood the programming model. "Structures" usually refers to data structures, but in an OO language these are usually …

Member Avatar for whit89
0
162

The End.