7,116 Posted Topics
Re: There is a missing semi-colon on line 132 of your code. | |
Re: > I could get my validateInputs() to return a boolean value of false if an exception has occurred and true if it hasn't, pass that back to the caller and take it from there. Without going into all the details, that sounds like a good idea. In general it's a … | |
Re: I too had these problems when trying to access DW from my iPhone this afternoon. It insisted on all kinds of obtrusive offensive and and irrelevant questions before it would deign to let me get into DW to see if anyone wanted any Java help. I had to give random … | |
Re: 1. Yes. Swing calls paintComponent when needed. Resizing the container os one reason why a repaint would be needed. 2. rand.nextInt(255) returns a random int in the range 0-254, not 255. The Color constructor takes three values 0-254 representing the red/green/blue components of the color, so that whole code creates … | |
Re: Mixing stream types on a single socket is guaranteed to cause chaos, so pick one type and stick to it. Object streams are the obvious way to go because they are most capable and simplest overall. You can create a simple protocol to allow you to send different kinds of … | |
Re: Yes, you need to catch the NumberFormatException that's thrown when the user input is not numeric. > I would have thought that the InputMismatchException would take care of it No. When in doubt, read the API documentation, eg * public static int parseInt(String s) throws NumberFormatException Parses the string argument … | |
Re: By calling a method that either accepts the variable as a parameter, or returns it. Doesn't matter if its a simple value, or an array, or whatever. | |
Re: > The text file can become very large and opening then closing it, then opening it again to start reading the updates is highly inefficient and I am searching for an alternative. I guess you missed that? (not to mention this thread has been dead for 6 years) | |
Re: Hi Zaraki (and Kriti) Please note that it is DaniWeb's policy that posters should show some effort before we give them help. "Please do my homework for me" posts are usually either ignored or penalised. Having said that... Z's post is good in that it points OP in the right … | |
Re: When you call `parseDouble` passing a string that cannot be parsed as a number Java will throw a `NumberFormatException` You can put your `parseDouble` inside a `try` block and `catch` the exception - your catch block will be executed if and only if the string does not represent a valid … | |
Re: I thought this question was how to handle a Java Object (that happens to be a Boolean) in cpp code? If it's a Java question then you need to cast the Object to Boolean (maybe checking first that it is an `instanceof` Boolean). Java will handle conversion between a Boolean … | |
Re: There are all kinds of algorithms that come under the heading "self learning software". You can write any or all of them in C# or Java Your question is far too vague and large to expect anyone to try to answer it in its current form. I suggest you spend … | |
Re: Try printing sqlString to check its syntax. Run that exact string at an sql prompt and see what it does. | |
Re: If you input 3 is the output wrong or right - you say both! 11 and 17 are also prime numbers | |
Re: Java GUI, Socket communications, multi-threading, video compression... This is a complex application that requires a wide range of skills. Perhaps you should do something simpler first. | |
Re: OK, a couple of observations... when you click menu you don't reset `value` what is `iterate` all about??? to stop falling off the end of the array you just need to test for it, ie (pseudo code) `if value = last element in array: do nothing` `else display array[++value]` ps: … | |
Re: Class names usually begin with a capital letter, eg Connection. (Java is case-sensitive) Re your `catch` block: If/when there is an error you just told Java that you didn't want to know anything about it, and please discard the detailed error message that Java just created for you. ALWAYS put … | |
Re: I don't speak android Java, so what's *env ? | |
Re: I've been programming since 1969 and I don't know how to use them properly either. Neither do the combined resources of Microsoft, Adobe etc, judging by the number of memory-related security errors that they keep finding in their released code. Pointers are far too error-prone and dangerous for anyone other … | |
Re: Inside your nested loops just use the `equals` method to compare `t[i][j]` with the target string. | |
Re: If you really understand nothing then you may as well give up now. But I suspect you know more than that. You have been told what to do step by step. Start at the beginning, do what you can, and when you get stuck post what you have done, and … | |
Re: You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrespectful 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: Can you explain further? Once you have set up the socket connection you have two Streams available (one going each way) so either end can send whatever it wants to the other. What is worrying you exactly? | |
Re: Do you think this is a free "we do your homework" service? Stop trying to cheat, an do your own homework. If you try, and have a problem, come back here, show what you have done, and explain what help you need. | |
| |
Re: You didn't say what help you need! | |
Re: > In other words how would your new formatter know the end of a comment? It would have to make guesses such as "Hmm, a // might end when I find ???" I get the feeling an AI class would have to be made. The JLS specifies Java's syntax with … | |
Re: You probably don't need the full power and complexity of Java to do this. A simpler scripting language will probably do. I've tagged this post with a javascript tag so it will be visible in the appropriate forums. JC | |
Re: 1. What is the printLine method for? Why not just print the text? 2. The printLine method is where you always print a blank before every line 3. Your code does not handle the case where there is more than one } or more than one { on any one … | |
Re: Instead of drawing directly to the panel's Graphics, create a new Image and draw to its Graphics. Then just copy that to the panel using `drawImage` and also save it as a jpeg ps: Updating the random numbers inside paintComponent is a really bad idea. You have no direct control … | |
Re: Yes. `private` fields can only be accessed within the class where they are declared. You need a less restrictive access type such as `protected` or *`default`*. This tutorial expalins it better than I can: http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html ps Lines 11/12... because a superclass's variables have to to be initialised before its subclass's … | |
Re: As far as I can see that code should return the department name followed by the number of staff in that department (or "" if there are no staff in that department), and it will always return exactly the same result unless you are changing the contents of `staff` outside … | |
Re: Seriously? You want us to help with an error in your code, but you don't tell us what the code is or what the error message is? We're not mind readers. | |
Re: If you are a beginner (which is obvious from the question) then forget Eclipse. Eclipse is a very powerful massively complex tool for experts. It has its own learning curve every bit as long as the learning curve for Java itself. Just download the JDK from Oracle, find a text … | |
Re: You could build a simple form with an entry fields (or drop-down lists) for each column in the database. Whatever the user enters you use as search criteria. You could have a check box next to each field, and if it's checked you summarise the results by summing over each … | |
Re: I tagged this "java" so the right people wil see it. Show what effort you have made so far. What the heck does "one toss of a die is equivalent to one experiment. In one experiment a die is rolled 50 times." mean? | |
Re: We don't have tutorials as such here - mostly because there are so many tutorials on the web already. As always I recommend the original Sun/Oracle tutorials. They are the most complete, the most correct, and the most up-to-date. http://docs.oracle.com/javase/tutorial/reallybigindex.html | |
Re: You are nearly there. In the client, do not calculate the surface. Send the radius and the height to the server. Wait for the reply and extract the area from that. In the server, extract the radius and height from the received message. Calculate the area. Send the area back … | |
Re: Sorry, but this makes no sense at all. Are we talking about files or classes? Can you give more details or better examples? | |
Re: Before doing a lot of work, and possibly constructing harder-to-maintain code, maybe you should check your assumptions? How about a trivial program to create and detach 1,0000 threads and see how much CPU that actually takes relative to all the other stuff that's needed to service each request. Shouldn't take … | |
Re: That question is not clear. Please explain your question with more details. | |
Re: In Java char is a 16 bit unsigned numeric value, so zero is perfectly valid anywhere, but the Java equivalent of your loop wold be something like `for (int i = 0; my-char-array[i] != 0; i++) {...` of course that will give an array index out of bounds if the … | |
Re: Because it was 4 years ago, and the people involved are no longer here, all the info we have is in this thread. If you now have the same problem, or a similar one, please start your own new thread and someone will help. | |
Re: You define the function with 3 parameters, but call it with 2 | |
Re: Are you trying to create code that will run something with elevated privileges without the user needing to input an admin password? | |
Re: You are using classes that are not part of standard Java, and so we have no documentation for them. In general you can't cast to a primitive type (int etc) because these are not classes. Only their corresponding classes (Integer etc) can be directly converted to primitives by Java ("unboxing"). … | |
Re: Having a method and a data member with the same name `adj` is bound to lead to confusion. |
The End.