7,116 Posted Topics

Member Avatar for xixi.li.7
Re: Java

Regardless of what your prof may or may not have said, DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules When you signed up for this web site you agreed to abide by all its rules.

Member Avatar for JamesCherrill
0
93
Member Avatar for jalpesh_007

Here's what your code is doing at the moment... iterator1 = ... iterator2 = .... while (iterator1.hasNext()) { ... while (iterator2.hasNext()) { ... } // after the first pass you have now used up all the elements in iterator2 // next time round the outer loop iterator2 will still be …

Member Avatar for JamesCherrill
-1
1K
Member Avatar for poojavb
Member Avatar for fariajan.siddiqui

file.getName() just returns the file name - any path info is lost. So unless the file happened to be in the current working directory it won't get found just from the name. You could try getting the full path & name to identify the file fully, eg file.getCanonicalPath() rather than …

Member Avatar for JamesCherrill
0
108
Member Avatar for jyotikalra14

Please check the Daniweb member rules before posting http://www.daniweb.com/community/rules DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments"

Member Avatar for JamesCherrill
0
31
Member Avatar for kovidd

A lot depends on where you may want to go afterwards. If you see a career in enterprise Java then go with EE-specific technogies like servlets and jsp. On the other hand if you just want to improve yur general Java and programming skills then build something using Java SE …

Member Avatar for ~s.o.s~
0
229
Member Avatar for Hemanth.Satkuri

Stack overflow is usually caused by recursively calling a method from itself. (Too many objects created normally throws a OutOfMemoryError exception, not a stack obverflow.) The error messgae tells you the exact line in your code where it happened. Without that info we can't do anything.

Member Avatar for JamesCherrill
0
185
Member Avatar for Hemanth.Satkuri

Perhaps a modal dialog will meet this requirement if it happens during the exceution of your code? If you want this to display while your program is loading/initialising then Java 6 has splash screen support to do exactly that http://docs.oracle.com/javase/6/docs/api/java/awt/SplashScreen.html

Member Avatar for dmanw100
0
130
Member Avatar for adityawkhare

I don't know of any such standard component, but you could simply disable the button in its actionPerformed listener to stop it being triggered again.

Member Avatar for JamesCherrill
0
65
Member Avatar for theQube
Member Avatar for JamesCherrill
0
254
Member Avatar for gelmi

What coordinates? In what way "more accurate"? I think you need to explain this question in a lot more detail.

Member Avatar for JamesCherrill
0
110
Member Avatar for im abcd

If you have the default installation then your jar is being run by javaw.exe, not java.exe That means there is no console window, so you don't see any IO from a program that just uses the console. Try running the jar with java.exe in a command window.

Member Avatar for im abcd
0
467
Member Avatar for godzab

@godzab: In the example you gave, do you want to remove the 2 from java. lava, or both? What if there are duplicate entries in either one of those two lists? ps: Guys - what's all this fortran-style for looping and hand-coded searches? This is Java, we have enhanced for …

Member Avatar for JamesCherrill
0
294
Member Avatar for mclam

Hello Anil Your solution comes 8 years too late for the OP, and anyway we don't do peole's homework for them, we try to teach them to do it for themselves.

Member Avatar for JamesCherrill
0
166
Member Avatar for iash

DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question This thread is closed.

Member Avatar for JamesCherrill
0
112
Member Avatar for rozina11

DaniWeb Member Rules include: "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
290
Member Avatar for jimmyjhonrubio

> Java variables must be initialize when you use them. > String name = ""; etc etc They must be initialised before you use their value, but that does not mean that they must be, or should be, initialised when you declare them. Initialising like that is only useful when …

Member Avatar for JamesCherrill
0
211
Member Avatar for WDrago

Obviously you can pass a reference to the text area into the processing code and thus update it directly, but that would totally undermine your correctly-engineered architecture. Or you could use the "observer" pattern and enhance your processor code to allow you to add a ChangeListener to it. Then you …

Member Avatar for WDrago
0
216
Member Avatar for Dev.Waleed

How far have you got now? Have you installed the JDK? If so, that's all you need for now for ordinary Java development. You don't need any other plugins or libraries. A programmer's editor such as notepad++ would be useful but not essential. Did you follow the tutorial link Norm …

Member Avatar for stultuske
0
236
Member Avatar for hemanth.balaji

DaniWeb Member Rules include: "Do not hijack old threads by posting a new question as a reply to an old one" http://www.daniweb.com/community/rules Please start your own new thread for your question, post the relevant code, and the full text of the error message This thread is closed.

Member Avatar for JamesCherrill
0
758
Member Avatar for nitigya

DaniWeb Member Rules include: "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
48
Member Avatar for Tomi1988

Don't invent your own mwthod signatures. Look at the `Comparable` interface in the API doc. If your class implements its `compareTo` method then you have a standard way of comparing your objects. This is how the standard sort methods work as well.

Member Avatar for JamesCherrill
0
141
Member Avatar for ctclements

It's integer arithmetic, performed in integers throughout. eg (10/20)x100 10/20 in integer = 0 - there's no fractions in integer values 0x100 = 0 on the other hand (10x100)/20 10x100 = 1000 1000/20 = 50

Member Avatar for ctclements
0
207
Member Avatar for drogba123
Re: SHA1

There's something odd about the file reading. In main you read a file one line at a time then pass that line to calculateHash as a String. But in calculateHash you treat that String as a file name and try to read lines from that file. Unless `C://Users//NTU//Desktop//hash.txt` contains file …

Member Avatar for drogba123
0
470
Member Avatar for minimee120

You can add a number to a running total with a simple addition eg total = total + nextNumber; every time you execute that witha new value for nextNumber the total will increase.

Member Avatar for NormR1
0
248
Member Avatar for beholdafrica

Maybe a bit harsh, stultuske? Probably the most important thing in chosing a big project is that it should be something you're actually interested in and know something about. I might want to build a wine database, but maybe you would rather do a badminton league / knockout competition application. …

Member Avatar for stultuske
0
171
Member Avatar for kinjal.shukla.77

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 doing your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting …

Member Avatar for stultuske
0
81
Member Avatar for adudarko.kingsley

Yes, there are lots of people here who can help you, but please check the Daniweb member rules before posting DaniWeb Member Rules include: "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
43
Member Avatar for WvTxMan_1

There may be a problem with your ItemStateChanged methods. They will be called whenever the state changes - ie they become selected *or deselected*, but your code is intended to run only when the state becomes selected (?)

Member Avatar for JamesCherrill
0
203
Member Avatar for keithlouie.manalon

DaniWeb Member Rules include: "Do post in full-sentence English" "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 WDrago

I would keep the main method in the project class and ignore/discard the one in the JFrame class. My reason is that starting a program, in general, is more than just opening the main window. In real life you may need to create a database connection, start a server instance, …

Member Avatar for WDrago
0
936
Member Avatar for dnanassy

1. Use a file open dialog and let the user chose the file. (Easy, but requires user involvement) 2. Use System.getProperty("user.home") to get the user's home directory and place the file there (or in a specified sub-directory). There's always a user home dir, even though it may be in completely …

Member Avatar for dnanassy
0
508
Member Avatar for Kayla1993

> .Throw an error if the input number is less than zero. You missed this part out. The catch is OK, but you don't throw the exception when the input is wrong.

Member Avatar for mlesniak
0
119
Member Avatar for venividivici

Client/server coms via Java internet Sockets really isn't hard - [here's](http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html) a good short tutorial to start with. A server for synch and gamestate etc is a perfectly reasonable way to go. SQL would be another area of complexity to master, so maybe better left for version 2? Java language …

Member Avatar for JamesCherrill
0
163
Member Avatar for WDrago

You could pass the (reference to the) ArrayList to the constructors of the various dependent classes so they all have access to it when their instances are created. Giving them direct access to the list (via passing refs or sharing a global) can be dangerous - anyone can make any …

Member Avatar for WDrago
0
107
Member Avatar for HankReardon
Member Avatar for NormR1
0
188
Member Avatar for Ravish.Ahmad.Khan

The ArrayIndexOutOfBoundsException meesage includes the line number where it happened, and the index value. Both these are critical info for finding the bug.

Member Avatar for Starstreak
0
173
Member Avatar for io.caraballo

I agree with rubberman. Start with UML uses cases -> class diagrams -> sequence diagrams. Once you've done that you have the basic structure of your code (classes / important variables / public methods) all planned out. See the first few sections of [this](http://www.ibm.com/developerworks/rational/library/769.html) Personally I'm no fan of state …

Member Avatar for JamesCherrill
0
239
Member Avatar for iEpic

If you want to play that game... static final String[] romans = {"I", "II", ... etc ... if (num>=1 && num< 10) JOptionPane.showMessageDialog(null, romans[i-1]);

Member Avatar for JamesCherrill
0
217
Member Avatar for rahul.ch

The equals method is defined in the Object class, so in the API docs you will find it listed in the "inherited methods" section. That version of equals tests for the the objects being exactly the same object (at the same memory address), so that's what you get if a …

Member Avatar for rahul.ch
0
322
Member Avatar for rahul.ch

Sorry stultuske, but I found your reply very confusing. Once you create an instance of some concrete class that instance can never change its type. A SampleB can be added to a Vector<SampleA> because SampleB is a subclass of SampleA. But nothing is "stripped from the instance", and a SampleB …

Member Avatar for rahul.ch
0
228
Member Avatar for london-G

1. Never, that's NEVER, have an empty catch block when you are devoping code (lines 27-30). How will you know if Java has detected an error? Always start with an `e.printStackTrace();` in every catch block. 2. If you do that, but there are no exceptions thrown, then add print statements …

Member Avatar for london-G
0
214
Member Avatar for jemz

You don't have to put the source code in the jar, so don't! You do have to put the class files, so there's no way to stop someone looking at the byte codes and trying to reverse-engineer a source version. You can use a tool called an obfuscator to remove …

Member Avatar for jemz
0
102
Member Avatar for Phadefrequency

DaniWeb Member Rules include: "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
5K
Member Avatar for dantheman4

> I changed the increment to a preincrement instead of postincrement; the performance is a little better. This may have been true some time in the distant past (by "a little better, maybe 0.00001% faster overall?), but for any current compiler these three forms should generate exactly the same optimised …

Member Avatar for NormR1
0
228
Member Avatar for yup790

"Teach yourself Java in 21 days" reminds me of the classic guitar teaching book "Play in a day", as used by Eric Clapton etc. It takes a lot lot longer than 21 days, or 21 months to learn Java. After 21 years you'll still be finding new classes in the …

Member Avatar for JamesCherrill
0
203
Member Avatar for dantheman4

The requirement includes a parameter thats passed to the compareParity method, but your method has no parameters.

Member Avatar for JamesCherrill
0
109
Member Avatar for sidhartha93
Member Avatar for NormR1
0
49
Member Avatar for aabbccbryanmark

It's integer arithmetic, normal maths priority, so cor/10 = 0 (would be 0.3333, but this is integer math) 0*50 = 0 0+50 = 50 To fix it, change the order of your expression so the * is done before the /, ie cor*50 = 150 150/10 = 15 15+50 = …

Member Avatar for JamesCherrill
0
112
Member Avatar for rvijaya

Do you have an error message (eg something about static context?). If so please post the exact complete message (copy/paste, don't summarise it)

Member Avatar for rvijaya
0
154

The End.