7,116 Posted Topics
Re: Variable c is null, so it’s not an array and line 10 will give a null pointer exception. You need to initialise c to an array of the right size before you try to set any of its elements. | |
Re: Please give more details of what you are trying to do, and exactly is the problem that is preventing you from making progress. | |
Re: This is marked ‘solved’, so can you take a moment to share your solution for the benefit of others? Thanks JC | |
Re: It looks like you have been experimenting with a variety of layout mangers! Firstly - have you seen the Oracle tutorials - they are excellent. They start here: https://docs.oracle.com/javase/tutorial/uiswing/layout/using.html In my experience they are all too simpistic for anything but the simplest of requirements *except* GridBagLayout and SpringLayout. SpringLayout was … | |
Re: Very interesting. Did you just want to share that, or is there a question? | |
Re: Hi zebnoon Sorry, but it does look like there's nobody around at the moment who can help you. People do have very full and busy schedules, but with any luck someone with the necessary knowledge will get a free moment t help you. JC | |
Re: One thread can both read and write a volatile variable, all the other threads can only read it. You say you are aware of the concept, so what exactly is confusing you, and what exactly do you want an example to show? | |
Re: > EIQ Studio's In English there is no apostophe in the plural "Studios". Not a good start. Is this a) a scam b) wishful thinking by some teenager in his/her parent's bedroom or c) a real thing... ... in which case maybe you should concentrate less on using unskilled labour … | |
Re: Yes, very interesting. Did you have a question? | |
Re: I know this is marked "solved", bt for the benefit af anyone who has the same problem... To quote from the API doc... > It is imperative that the user manually synchronize on the returned map when iterating over any of its collection views so the loop on lines 70-72 … | |
Re: You can check for the two `Shapes` (ellipse and rectangle) intersecting. Which side is then just a tedious testing of the x and y coordinates. Bouncing off a side of a rectangle (assuming it;s horiontal/vertical) is trivial (1), but bouncing off a corner is a different question. If you get … | |
Re: The wait method releases the thread's lock. | |
Re: > According to the output it seems finally was not executed despite the try block getting completed. ? line 3 of the output appears to be the message from line 23 in the finally block so it looks to me like the finally is being executed. Be careful when reading … | |
Re: No time for a proper answer now, but here's some code I use that I modified from something on the web that bounces balls a and b that have position x,y and velocity dx,dy. I gives bounces that look very realistic to me. It's very similar to your code, double … | |
Re: > If I let the programm run it prints out an infinite number of the maze I choose It looks like the program wil print the entire maze each time it tries each step in finding the solution - so not infinite, but just far too many. Starting to debug … | |
Re: Can’t you just use the page width that the PrintFormat parameter will give you? | |
Re: Leaking in constructor... The language spec only guarantees that the new object will be in a complete and consistent state *after* the constructor has finished. When you add the key listener you pass a reference to you current object, so it's immediately possible for another class to call methods in … | |
Re: Like he said... plus specifically: do you get "in here" printed 30 times per sec? | |
Re: I think the obfuscation/hacking issue is much over-rated. Although decompiling and modifying a jar is possible, few people have the necessary skills and even fewer can be bothered unless it’s a really desirable program with too high a cost. If you set a sensible price then it will be less … | |
Re: There's no need to be rude. A polite request will get a better response. | |
Re: > public Renderer Renderer; You have a variable with exactly the same name as a class. Surprisingly this is valid Java, but it's making your code imcomprehensible. It would be much easier to read if you follow Java conventions and start class names with a capital, variable and method names … | |
Re: We are here to help people who are trying to work hard and learn. We are not here to do Google searches for people who may be too lazy or too stupid to do their own searches before asking a question. Correct your attitude and try again. | |
Re: It's called a "bubble sort" - just Google for details. Apart from tjhat it just copies a List of students into an array so the sort will be fast, sorts the array, then copies the sorted reults back into the list. That part of the code should work, but it's … | |
Re: If you want to convert a String (eg from a JTextField) to a BigDecimal you can use one of BigDecimal's constructors... String s = " 1234.56"; BigDecimal bd = new BigDecimal(s); | |
Re: > It would cause quite some security concerns if it did. Indeed. Do you really think browsers and users will have zero protection against some random web site deleting their files so easily? You need to re-think your application design to avoid the need to do this. | |
| |
Re: OK folks, getting a bit off-topic here?... it's Java. John: I don't see how you got from the problem definition to that code. It looks like you have tried to adapt a different program, with arrays of numbers and primes somehow. Hacking a different program is almost always a bad … | |
Re: What's a "PPS number"? The java.util.Random class has methods for generating random ints, arrays of random bytes etcetc | |
Re: > heyy can anyone please help me with this homework yes, there are many people here who will help you. But that means "help you to learn how to d o it yourself". Nobody will do it for you. Show what you have done so far, and explain where and … | |
Re: The C++11 Standard says that signed integer overflow/underflow behaviour is "undefined", so any compiler can legally do whatever it wants, including ignore it. Ignoring it (on normal computers) is a lot easier and faster that detecting it and doing something sensible. That's C++ for you. > 8.4: If during the … | |
Re: Sam: You have not asked a sensible question. We have no idea of what you already know or what help you need. Please read the link RJ gave you and then try again. We do help people, but only those who show some effort and ask answerable questions. | |
Re: Where is your `main` method? The code lines 9 etc should be in `main` if you want them executed! | |
Re: > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException A null pointer means an unititialised variable (or a return value from a method that returns null) > at Chapter12.TheaterGUI$buttonListener.actionPerformed(TheaterGUI.java:84) You have the original code, so you know which line that refers to So check that line to see which variable is null (if … | |
Re: Probably the easiest way is to put all the words in a TreeMap (for fast searching) then check every permutation of every subset of your letters to see if it's in the TreeSet. However that will generate a lot of searches if you have a lot of letters, which may … | |
Re: Line 49 you fail to initialise `i` (which is also used in many other methods) so your loop may or may not execute any number of times. Insert prints "true" because that’s what the insert method returns | |
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 coding your homework for you. DaniWeb Member Rules include: "Do provide evidence of having done some work yourself if posting … | |
Re: > NEED THE CODE FOR THIS: That's not what you need. Try again. I can post you an honors degree certificate if thats what you think the world owes you. | |
Re: Harish 1. Your code is unreadable - a solid mess of undocumented stuff strung end-to-end without any thought towards making it comprehensible. It even has gotos! It's useless. 2. Can someone do the AI part of your school project for you? As in cheat? As in get an unfair advantage … | |
Re: Ty_1 1. Do not hijack old topics for your new question. Start you own new topic. 2. If you do not post your code then nobody can tell you what you are doing wrong! | |
![]() | Re: Well, the people who wrote it know how. They even documented it on the web. You even posted a link to that very page as part of your question! What exactly is it you need to know that’s not covered there? |
Re: > Between or inclusive? The header docs seem clear on this. Dietrich: You have code there, so what is your question exactly? ps: HINT: You should check the API doc for Random's `nextInt` - specifically what range of values it returns. | |
Re: > What if your compiler thinks you mean ... > Why it matters is that your compiler may do that test first as it is low cost. I hate to be a pedant here, but the C language clearly defines the priority of operators, and if your compiler does something … | |
Re: Hi balajisathya88 Please be aware that there is a policy on this forum of not just giving people the code they need for their homework. People learn best if you point them in the right direction (eg a tutorial, or the name of the class/method they need), then let them … | |
Re: That is a very vague and general question. Please ask something more specific so people can answer | |
Re: It looks like the spec is badly written Although the method is called "printAll Nums" the spec does NOT say print the numbers, it says return a string (that could be printed). So, don't be distracted by the misleading method name, just read the spec carefully and return "the string … | |
Re: Pietiläinen Just a guess... Is it possible that you are using a one byte character set where the a-umlaut is a 2-byte extended code? (easy to check - just replace it with an ordinary a and see what happens) | |
Re: Need code <copy of teacher's spec>? No. You first need to learn to be polite and ask sensible questions. You obviously ignored the "[Read This Before Posting A Question](https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question)" topic at the top of the page. Read it now, then start again and someone will help you. | |
Re: Yes - as above. In fact all your loops and if/else blocks need brackets. The code inside your loop line 15 will be executed for the "end of input" value (<=0), which will corrupt your results. Also `smallest` is initialised to zero, so `if (mark < smallest)` will never be … | |
Re: DaniWeb Member Rules (which you agreed to when you signed up) include: "Do provide evidence of having done some work yourself if posting questions from school or work assignments" https://www.daniweb.com/welcome/rules Post what you have done so far and someone will help you from there. |
The End.