7,116 Posted Topics
Re: Because you want to make many Strings in a normal program, Java has special syntax to make it easy, eg. String name = "Joe"; without that you would have to say something like char[] letters = {'J', 'o', 'e'}; String name = new String(letters); So it is in the language … | |
Re: > I want to construct an Employee class and solve the error. Before you get bogged down in Java syntax, think about the meaning of what you are trying to do. You can read a for each in English like this: for(int i:e){ // for each int (which I will … | |
Re: Line 8 is wrong. There is no `nextInt` method in System.in You must create a Scanner using System.in (just like your previous post) Then you can use the Scanner's nextInt method to read an int value that you can assign to rno ps: If you have the answer for your … | |
Re: 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) … | |
Re: You declare `String test` on line 9 of a. When you declare a variable in Java its scope if from the preceeding '{' to the following '}'. In this case that `test` variable exists just from line 8 to line 13, after which it is discarded. You presumably have another … ![]() | |
Re: An interface defines a set of methods that must be implemented by any class that implements the interface. Eg You could define an interface with a calculateArea method. Then define all kinds of shape classes (Square, Circle etc) that implement the interface. Those classes may have a common Shape superclass, … ![]() | |
![]() | ![]() |
Re: `in` is a public constant in the System class. It refers to an InputStream object that gets the input from the console. Here's part of the API doc for the System class: > public static final InputStream in > > The "standard" input stream. This stream is already open and … | |
Re: There's an alarm bell ringing over this line... program.run(); You (almost) never call `run()` directly in Java. The `Runnable` interface is intended for use with Threads - ie you instantiate a Thread object using the object that has the run() method, then call `start()` for the Thread object. The Thread … | |
Re: A good start would be to separate the GUI code from the newtworking code. Refactor it into two classes so you can create and swap a new instance of the network class without creating a new GUI class instance. | |
Re: You didn't post the declaration of testgui, but apparently it's not a subclass of Component. The ".this" is even more mysterious. | |
Re: In your `stringInts(int[] ints)` method, test if each value is -1. Only add it to the output String if it is not -1. | |
Re: Yes, I agree. Scanners are supoposed to be easy, but in reality seem to cause a lot of problems. If you use a BufferedReader, and readLine() to read whole lines you can parse their contents yourself and be sure exactly what is happening. PS A small typo from DoogleDude there … | |
Re: Excellent Questions! The constructor for Insets is `Insets(int top, int left, int bottom, int right)` (source: API doc) so you added 10 at the top. Re your 5x5 grid... yes you can put your components into non-contiguous cells, but if you leave a whole row or column empty its height … | |
Re: Write the count variable to a `PrintSream` - that will write it as a String that you can check by opening the file in any text editor. Read it back in as a String then use `Integer.parseInt` to convert that back to an int variable. [This](http://www.dreamincode.net/forums/topic/27972-reading-and-writing-to-a-file-in-java/) is a beginner-level tutorial … | |
Re: Have you tried getColumnLabel instead of getColumn Name ? | |
Re: You can break out of the loop as soon as you have found a match, ie: for (int i ...) { if (prog....) { display token break; } | |
Re: Prabhet: I'm sure you intended to help, but here we try to teach people the knowledge and skills they need. We don't just do their homework for them. If you do want to post code here as an example or solution you should be careful that is is a good … | |
Re: Unless there's some reason why to *has* to be an ArrayList, by declaring the variable as a List you allow the possibility of (eg) changing the implementation to a LinkedList sometime later, secure in the knowledge that you will not break any existing code. | |
Re: An nested class has access to the variables and methods of its enclosing class, and it can be private to the enclosing class. That's a completely different kind of sharing and encapsulation compared to a separate class. Which you chose depends on what you need. Consider a Listener class in … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here. There are lots of people here who will freely give their time to help you become the best Java … | |
Re: Maybe `wallSwitch` needs to be an attribute (instance variable) of the Enemy class, so each Enemy has it's own value for that variable? | |
Re: > You have to add System.exit(0); at the end of your code, otherwise javac won't work properly. Sorry, but that is completely wrong. System.exit is always optional, and is mostly too dangerous to use in production systems. | |
Re: That code is completely unreadable - blocks that go on forever, no comments, no indentation... But as far as I can see the order of creating the frame is maybe wrong and missing steps. You should: create the JFrame add all the components pack(); the JFrame (couldn't find this in … | |
![]() | Re: Hello divya, welcome to DaniWeb Please do not hijack old threads with your new question. I have deleted your post so you can create your own new thread. You may also want to post the relevant code - it's hard for someone to say what you did wrong if they … |
Re: Rather than overriding paint, you;ll be on easier ground by creating a gridlayout of JLabels and using ImageIcon to place your graphics in the JLabels. (just Google it) If you must override paint then don't re-load the images from disk every time paint is called. It can get called very … | |
Re: To hold the info for multiple rectangles you need multiple sets of coordinates (x1, y1, length, depth). You could use arrays to hold them, or some kind of List or Set from the Java API. | |
Re: That's a pathetic post. If you want some help you'll have to provide a LOT more info than that. Do you think we are all mind readers? | |
Re: Forget rmic and stubs. They have been obsolete for years. For current tutorial info and a working sample [this](http://docs.oracle.com/javase/tutorial/rmi/index.html) is a good source of info. | |
Re: 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) … | |
Re: Please explain exactly what is confusing you. I assume you have Googled these questions and read some of the standard answers. | |
Re: You inherit from a superclass when defining a subclass with the `extends` keyword. You instantiate an *instance of* a class at runtime when you use the `new` operator. | |
Re: 31: rolls[diceValue - 1] = rolls[diceValue - 1] += 1; That is positively *wierd*. Two assignments for the same variable like that - I'd have to read the JLS to know which was executed first! What's wrong with rolls[diceValue - 1]++; Ditto line 58, except that I don't know why … | |
Re: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Thread closed. JC | |
Re: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" http://www.daniweb.com/community/rules Thread closed JC | |
Re: You read the first line (17) then use its tokens to add columns (20). You then read the rest of the lines (22) and use those to add rows (25). That's why the first line of the file goes to the column names. | |
Re: at PPMSPrototype.initComponents(PPMSPrototype.java:841) That's the line in your code where you try to use a null reference. Looks like that's trying to create or use an ImageIcon? 10 will get you 20 that it's a problem with the path to the file where the image is stored. | |
Re: Most of the symbols it can't find are the names of standard API classes, so it looks like you forgot (some of) the `import` statements at the start of your .java file(s) | |
Re: mukind: Answer is NO. Do your own homework. People here will help if you show some effort first. | |
Re: 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) … | |
Re: Those 2 code fragments don't quite add up, but... you have a 2D array 4x3, so the array's length is 4 in your loops you use the length to control the loop for both indexes, so you will have a problem with the second index. In Java it's misleading to … | |
Re: Is this the same problem as the "all subsets of a set" that you posted 4 days ago? | |
Re: You want to run an app in another jar when a button is clicked? The easiest way is to use the Desktop class which can open a file in its default application - if you open the other jar file then the default will be to run it using javaw. … | |
![]() | Re: 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) … ![]() |
Re: What is the exact complete error message? | |
Re: OK, let's not take over this thread with a separate discussion. SintherPal's post ignored two of the DaniWeb Community Rules: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" and "Do not solicit for help by email" Those violations would justify my … | |
Re: That's right, a bat file is not an application. The application that runs batch files from the command prompt is cmd.exe, so you need to execute something like cmd /c mybatchfile.bat etc ps from Java 5 onwards the preferred way to run Applications is via ProcessBuilder, not runtime exec. | |
Re: Your array has entries, [0] thru [4]. You try to access a sixth element` inventory[5]` because your loop on line 26 goes from i=0 to i=5 | |
Re: "stops working" means what exactly? You can force leading zeros by a) prepending eights zeros, then substring the last 8 chars of the result or b) add 256 to the value before converting to a binary string, then drop the first character or c) probably lots of other ways? ps … |
The End.