7,116 Posted Topics
Re: 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. | |
![]() | Re: 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 … |
Re: 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 … | |
Re: What exactly are the symptoms / errors that you have? | |
Re: 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 | |
Re: Do you mean join side-by-side, or overlay one image on top of the other? | |
Re: 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] | |
Re: int[][] myint = new int[2][2]; Your data is 3x3 but your array is only 2x2 | |
Re: Start here: [url]http://www.daniweb.com/software-development/java/threads/99132[/url] | |
Re: 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 … | |
Re: Forget the code for a moment... how (in English) would you check if two dates were equal / the same? | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: Please edit that and put the code in code tags, properly indented, so we can read it. | |
Re: 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... | |
Re: Depends on what the other type is (String? float? 2-dimensional array? GUI window?). Some of those conversions are possible, others are meaningless. | |
Re: 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 … | |
Re: 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. ![]() | |
![]() | Re: 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. |
Re: 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. | |
Re: 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. | |
Re: 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 | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: 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: " … | |
Re: The error message gives the line number where the error happened. Which line is it? | |
Re: 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. | |
Re: 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. | |
Re: 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] | |
Re: Are those characters '1' and '0' (ASCII values) or are they numeric 0 and 1? It makes a big difference. | |
Re: 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 … | |
Re: 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. | |
Re: 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 … | |
Re: 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] | |
Re: If I understand your question, then yes. eg ArrayList<String> = ... ArrayList<Vector<String>> = ... etc | |
Re: 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 … | |
Re: 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 ![]() | |
Re: 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. | |
Re: 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 … | |
Re: [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! | |
Re: 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 - … | |
Re: 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). | |
Re: 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 | |
Re: 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) … | |
Re: 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 … | |
Re: 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. | |
Re: 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 … |
The End.