7,116 Posted Topics

Member Avatar for moaz.amin.37

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 …

Member Avatar for 203428
0
231
Member Avatar for sasikrishnasamy

> 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 …

Member Avatar for jwenting
0
121
Member Avatar for moaz.amin.37

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 …

Member Avatar for moaz.amin.37
0
553
Member Avatar for Asabre

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) …

Member Avatar for JamesCherrill
0
465
Member Avatar for sing1006

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 …

Member Avatar for iamthwee
0
314
Member Avatar for nutandevjoshi

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, …

Member Avatar for iamthwee
-2
164
Member Avatar for TheFearful
Member Avatar for moaz.amin.37

`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 …

Member Avatar for JamesCherrill
0
134
Member Avatar for Slavi

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 …

Member Avatar for JamesCherrill
0
112
Member Avatar for Slavi

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.

Member Avatar for Slavi
0
199
Member Avatar for sing1006

You didn't post the declaration of testgui, but apparently it's not a subclass of Component. The ".this" is even more mysterious.

Member Avatar for sing1006
0
799
Member Avatar for Halkawt.Papula

In your `stringInts(int[] ints)` method, test if each value is -1. Only add it to the output String if it is not -1.

Member Avatar for JamesCherrill
0
209
Member Avatar for cb1991110

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 …

Member Avatar for Doogledude123
0
226
Member Avatar for Violet_82

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 …

Member Avatar for Violet_82
0
665
Member Avatar for Netherblood

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 …

Member Avatar for JamesCherrill
0
136
Member Avatar for vishalonne
Member Avatar for sing1006

You can break out of the loop as soon as you have found a match, ie: for (int i ...) { if (prog....) { display token break; }

Member Avatar for sing1006
0
287
Member Avatar for bonzie1923

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 …

Member Avatar for JamesCherrill
1
155
Member Avatar for Doogledude123

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.

Member Avatar for JamesCherrill
0
182
Member Avatar for Doogledude123

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 …

Member Avatar for JamesCherrill
0
203
Member Avatar for Terens92

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 …

Member Avatar for jwenting
-3
161
Member Avatar for hwoarang69

Maybe `wallSwitch` needs to be an attribute (instance variable) of the Enemy class, so each Enemy has it's own value for that variable?

Member Avatar for JamesCherrill
0
350
Member Avatar for Techboy52

> 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.

Member Avatar for stultuske
0
4K
Member Avatar for umaima_1

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 …

Member Avatar for mKorbel
0
201
Member Avatar for kevndcks

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 …

Member Avatar for happygeek
0
3K
Member Avatar for nidheeshkumar.r

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 …

Member Avatar for JamesCherrill
0
1K
Member Avatar for mc3330418

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.

Member Avatar for JamesCherrill
0
485
Member Avatar for firepower

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?

Member Avatar for Taywin
0
164
Member Avatar for Tinnin

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.

Member Avatar for Tinnin
0
4K
Member Avatar for quackyeji

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) …

Member Avatar for jwenting
-1
229
Member Avatar for Richa_2

Please explain exactly what is confusing you. I assume you have Googled these questions and read some of the standard answers.

Member Avatar for Richa_2
0
285
Member Avatar for surya55

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.

Member Avatar for Doogledude123
0
205
Member Avatar for Doogledude123

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 …

Member Avatar for Doogledude123
0
344
Member Avatar for jan.sehona.1

"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

Member Avatar for JamesCherrill
0
198
Member Avatar for jan.sehona.1

"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

Member Avatar for JamesCherrill
0
233
Member Avatar for sing1006

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.

Member Avatar for sing1006
0
675
Member Avatar for jed247

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.

Member Avatar for Daemon_CC
0
267
Member Avatar for masonketcham

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)

Member Avatar for masonketcham
0
268
Member Avatar for revertedlogic

mukind: Answer is NO. Do your own homework. People here will help if you show some effort first.

Member Avatar for JamesCherrill
0
337
Member Avatar for asifalizaman

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) …

Member Avatar for jwenting
0
177
Member Avatar for ntaraaki

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 …

Member Avatar for JamesCherrill
0
239
Member Avatar for anku83
Member Avatar for anku83
0
214
Member Avatar for James_30

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. …

Member Avatar for James_30
0
166
Member Avatar for Nnadozie

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) …

Member Avatar for iamthwee
0
150
Member Avatar for montjoile
Member Avatar for SintherPal

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 …

Member Avatar for SintherPal
0
283
Member Avatar for AbhishekTecnics

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.

Member Avatar for AbhishekTecnics
0
2K
Member Avatar for spopivich

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

Member Avatar for stultuske
0
428
Member Avatar for awsa.qwase
Member Avatar for Doogledude123

"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 …

Member Avatar for Doogledude123
0
5K

The End.