7,116 Posted Topics

Member Avatar for needhelpinjav

Post what you've got for the first part. Then explain why you are stuck at that point. Otherwize we will have no idea what it is you need to know.

Member Avatar for stultuske
0
290
Member Avatar for begueradj

When you define a variable you can initialise it with a single expression that returns a suitable value. You already know about [ICODE]int a = 99;[/ICODE] or maybe [ICODE]int secondsPerYear = 365*24*60*60;[/ICODE] so this is just a slightly more complex example [ICODE]int b = readF.getNumberOfLinesInMyFile();[/ICODE] What you cannot have is …

Member Avatar for JamesCherrill
0
325
Member Avatar for asif49

I suggest three classes - Employee and Job, just like you have now, plus Employer (or Company if you prefer). Think about it as if these were real things - you have a Company, and the Company manages a number of Employees and a number of Jobs and assigns Jobs …

Member Avatar for JamesCherrill
0
124
Member Avatar for javabeginner1
Member Avatar for javabeginner1
0
228
Member Avatar for Unsated

Your { and } are messed up. Format your code properly, with correct indenting of all the {} and it should be clearer. The line numbers in the error messages don't match the code you posted, so it's hard to understand, but [CODE]do }[/CODE] is probably a mistake

Member Avatar for Unsated
0
425
Member Avatar for TehCPP
Member Avatar for glut
Member Avatar for glut
0
1K
Member Avatar for mrar85

Here's an article that explains simply and briefly what this exercise is all about: [url]http://www.informit.com/guides/content.aspx?g=java&seqNum=248[/url]

Member Avatar for mrar85
0
2K
Member Avatar for matharoo
Member Avatar for matharoo
0
2K
Member Avatar for ragira

Start here: [url]http://www.daniweb.com/software-development/java/threads/99132[/url]

Member Avatar for JamesCherrill
0
37
Member Avatar for vaironl

You've made the common mistake of overriding paint rather then paintComponent. JPanel's paint method calls paint for all its child objects as well as calling its own paintComponent, but you have overridden it thus bypassing the calls to paint the label. Just override paintComponent instead of paint and let Swing …

Member Avatar for mKorbel
0
2K
Member Avatar for jhellr13

Forget the code for a moment... how (in English) would you check if two dates were equal / the same?

Member Avatar for stultuske
0
305
Member Avatar for frank33

This kind of thing isn't particularly rare, nor is it reserved for advanced users. One case you see very often is when you read bytes from a Reader while checking for end-of-file (returns -1 for number of bytes read), eg [CODE]if (int bytesRead = reader.read(buffer) >= 0) {...[/CODE] although the …

Member Avatar for stultuske
0
140
Member Avatar for evilweevil

stulkuske has already told you 1. to remove the ; on public static void main(String[] args); 2. you can't define a method inside another method definition. If you don't listen you won't learn.

Member Avatar for stultuske
0
2K
Member Avatar for lameraz

1. Have a public method in LView that performs the add function as you need it. 2. When the TitleView instance is created, pass the LView instance to it as a parameter in the constructor. Save a copy of the reference in an instance variable. 3. In your actionPerformed you …

Member Avatar for lameraz
0
170
Member Avatar for vinithktp
Member Avatar for vinithktp
0
903
Member Avatar for MisterRaver

My guess is that you cannot transfer an open connection from one IP/port to another while keeping it open. Why do you want to do this? Maybe there's another way...

Member Avatar for MisterRaver
0
261
Member Avatar for umair jameel

Depends on what the other type is (String? float? 2-dimensional array? GUI window?). Some of those conversions are possible, others are meaningless.

Member Avatar for JamesCherrill
0
78
Member Avatar for Labdabeta

If you are using Eclipse in a project with central code management and versioning just revert to an earlier version. If not, depending on how you're set up, you should be able to right-click in the editor window for the affected file(s) and select "local history" to restore your source …

Member Avatar for JamesCherrill
0
159
Member Avatar for Matth963

Add print statements after each line to print out the values that were set/changed on that line. Then you'll be able to understand how it works.

Member Avatar for hfx642
0
108
Member Avatar for begueradj

Your code calls displayListSize as part of the startup code in main, but the actionPerformed method isn't executed until you click the "new" menu some time later, so the two calls are in the wrong order.

Member Avatar for JamesCherrill
0
215
Member Avatar for swink11123

tempString[0] is a String, minValues[count] is an int. You can't assign an String to an int, they are "incompatible types". You can use something like Integer.parseInt to convert the String to an int, assuming that it contains a valid integer value and not just some random letters.

Member Avatar for JamesCherrill
0
106
Member Avatar for hhheng

In Java finalize() is pretty useless, mainly because you don't know when it will be called (the official answer is "sometime later, unless something causes it not to be called at all"). Better to save the coordinates before calling dispose(). Without seeing the other classes it's hard to say more.

Member Avatar for harinath_2007
0
255
Member Avatar for DarkVision

Bonjour. C'est bon, mais vous avez vos variables "static", c'est a dire que il-y-a une value pour tous les instances. Mauvais idée. Votre vache espagnole J

Member Avatar for JamesCherrill
0
102
Member Avatar for pmehalik46

In your rotate you seem to assume that chars 'A' to 'Z' correspond to numeric values 0 - 25 But that's not true. The letters are encoded as UniCode (same as ASCII for the English alphabet) so 'A' == 65 and 'Z' == 90.

Member Avatar for JamesCherrill
0
737
Member Avatar for tr4nquility

Maybe your problem is that you get and update the Graphics in mouseMoved, but Swing doesn't know that you have done this. Swing is by default double-buffered, so the screen isn't getting updated with your new line until something else happens to cause a refresh of the screen. If you …

Member Avatar for tr4nquility
0
908
Member Avatar for nchy13

I can't make any sense of your undocumented code, but in general: There is no restriction in Java anything like "only first function can access the variables." Methods can share variables that are defined at class level, but not any variables that are declared within a method. If you declare …

Member Avatar for JamesCherrill
0
169
Member Avatar for javausers

Although that approach can work, at least for a fixed size list of values, it's a pretty heavy way to overcome the OP's problem which was how to print an array of Strings. A better answer would be to use the Arrays.toString method, as in [CODE]System.out.println("Values of tree map: " …

Member Avatar for JamesCherrill
0
108
Member Avatar for danielagaba
Member Avatar for JamesCherrill
0
326
Member Avatar for SoniaC

Line 19, you use nextInt, which reads integer values (eg 123), but you want to read a char 'V' or 'N'. You could use next() to get the input as a String, then get the first char from that String.

Member Avatar for JamesCherrill
0
166
Member Avatar for persianprez

Maybe paintComponent is being called before you initialise point1 and point2? You could test for them being not null before you try to use them at line 34.

Member Avatar for JamesCherrill
0
129
Member Avatar for sidd1994

Simple typo, confused i's and j's line 14 et seq: [CODE]for(int [B][I]j[/I][/B]=0;[B][I]j[/I][/B]<l-1;[B][I]j[/I][/B]++) { if(str.charAt([B][I]i[/I][/B]) ... etc[/CODE]

Member Avatar for JamesCherrill
0
176
Member Avatar for nchy13

Are those characters '1' and '0' (ASCII values) or are they numeric 0 and 1? It makes a big difference.

Member Avatar for nchy13
0
2K
Member Avatar for nixufix

You only read in 1 word from the user (line 11). That needs to be in some kind of loop somewhere to read in the right number of words - either read them all into an array then process them, or read them one at a time and process each …

Member Avatar for JamesCherrill
0
1K
Member Avatar for caffrea4

Every public class must be in its own .java file with the same name as the class. You can't have 2 public classes in 1 file.

Member Avatar for JamesCherrill
0
98
Member Avatar for nchy13

It's how java keeps track of what classes are where: Every public class is defined an a source file called classname.java, and the compiled code is in classname.class (where classname is the (case-sensitive) name of the public class). Sp you need to rename your source file to HelloWorld.java (or rename …

Member Avatar for nchy13
0
407
Member Avatar for dennysimon

If you have one listener for multiple text fields then you can get the source of the event from the CaretEvent that's passed as a parameter to your caretUpdate method, eg [CODE]public void caretUpdate(CaretEvent e) { if (e.getSource() == myFirstTextField) { ... else if ((e.getSource() == mySecondTextField) { ...[/CODE]

Member Avatar for dennysimon
0
134
Member Avatar for Joey_Brown

If I understand your question, then yes. eg ArrayList<String> = ... ArrayList<Vector<String>> = ... etc

Member Avatar for JamesCherrill
0
103
Member Avatar for vaironl

What people usually do is something like this: 2 classes, Recipe - one recipe per instance, and Cookbook - one instance of Cookbook has lots of Recipes (eg an array of Recipes). Cookbook has the method that opens the Scanner, reads in the user's data, creates instances of Recipe (by …

Member Avatar for vaironl
0
126
Member Avatar for LondonJava

I haven't tried this (although I have used a similar approach to opening an InputStream to a file in a jar many times). But maybe its worth a try? [CODE]File f = new File((getClass().getResource("files/UserGuide.pdf").toURI()));[/CODE] You'll probably have to catch a URISyntaxException, although there should never be one

Member Avatar for hfx642
0
509
Member Avatar for Unsated

Of course we will help you through it. Make a start, and if you get stuck post the complete details of whatever it is that's stopping you progressing. What? You didn't expect anyone to do it for you, did you? That would be cheating.

Member Avatar for Unsated
0
373
Member Avatar for asif49

All you need is an Employee class, whose members include a collection (eg ArrayList) of Jobs, and a Job class whose members include an Employee (or collection of Employees if a Jab may involve multiple Employees). You can also have an Employer class whose members include a complete list of …

Member Avatar for asif49
0
161
Member Avatar for WigglesMcMuffin

[CODE]static String name; static double perDayCharge; static double maximumCharge;[/CODE] static means that there is only one value for this variable, and all instances of the class share that same single value. I bet that's not what you intended!

Member Avatar for WigglesMcMuffin
0
256
Member Avatar for programing

ClassOne [] a2 = new ClassOne [size]; creates an array of references to ClassOne objects, but initially all those references are null. You must initialise each element with a reference to an actual ClassOne. On line 21 you try to call the print method for an uninitialsed array element - …

Member Avatar for programing
0
83
Member Avatar for titusnainggolan

The return type for that method is defined as [I]void[/I], ie it does not return a value, so the is no return value to go with the [I]return;[/I] statement. The return; just terminates execution of the method (in this case because there has been a fatal error).

Member Avatar for JamesCherrill
0
309
Member Avatar for morred

You read in the data, change it in memory, then exit. Until you write the code to write the changed data to a file you will not see any changes. You can check your code so far by printing stringRad at line 29

Member Avatar for morred
0
170
Member Avatar for kyriacos1986

OK, a few subtle problems here: [ICODE]class Member implements Comparable {[/ICODE] Comparable is a "raw type", so your compareTo method has to take any kind of Object as its parameter. if you say [ICODE]class Member implements Comparable<Member> {[/ICODE] then (a) you no longer have a raw type warning, and (b) …

Member Avatar for JamesCherrill
0
181
Member Avatar for BIG J

You'll need a "main" method somewhere - that's the one that is run when your application starts. In that method you can create a new library, add books and members, and call your print method(s) to see if it's all working. And you'll need at least some code for your …

Member Avatar for BIG J
0
202
Member Avatar for javausers

Not enough info. Merge by concatenation, by joining records in input order, by joining based on a key value present in both files? Etc? Formats or examples of both files, and how are they to be merged (or an example output file) would be really helpful here.

Member Avatar for javausers
0
670
Member Avatar for tania123123123

It doesn't do anything because its an abstract class - you can't instantiate it. Also there is no "main" method to start the execution. To test this you need to create a second, non-abstract, class that extends ArithmeticExpression and provides full implementations for the inherited abstract methods. Then you can …

Member Avatar for JamesCherrill
0
186

The End.