2,777 Posted Topics
Re: Have you looked at the tutorial? http://docs.oracle.com/javase/tutorial/extra/generics/index.html Please post the full text of any error messages you are getting when you compile the code. | |
Re: You're probably having problems with the way the Scanner class works. Some times it returns an empty line when you use nextLine() after using next(). Printing out the values of the data read from the user will show if you are reading data as you want. Be sure to add … | |
Re: Lots of people here to help. Can you explain your problem? Post the code you are having problems with and ask any questions you have. | |
Re: You would need to use nested loops. Inside the inner loop, index elements in the array. If they are 0, change to 1. If 1 skip it. Count the numer of changes made and exit when done. | |
Re: Please post the code you are having problems with, your questions and the full text of the error messages. | |
Re: > i understand the problem Could you explain what the problem is? Post the full text of any error messages. | |
Re: Line 29 sets the array element to a 1. How often should that line be executed? What code controls how often that line is exceuted? You should not hardcode numbers to control for loops. See the 3 in line 17 and the 7 in line 19. These values should either … | |
Re: int digitValue = ch - 48; // now the number is really 2 Poorly documented code. Who knows what 48 is. Better would be: int digitValue = ch - '0'; // now the number is really 3 | |
Re: [QUOTE]irlce.java:23: incompatible types found : java.io.IOException required: char letter = get.ioException(); ^[/QUOTE] The error message says it all. What does the get object's ioException() method return? Is it the same type as the variable letter? What are you using the ioException() method for? lce.java:37: possible loss of precision found : … | |
Re: Is this the same question: http://www.daniweb.com/software-development/java/threads/436236/sales-receipt-program-from-cash-register-program Please don't start a new thread for the same question | |
Re: > I need to get a visitors location Where is that information available? Can you have the visitor/user select it from a list? Or type it into a textfield? | |
Re: What are you having problems with converting the posted code? Do you have any specific questions? Two things I see that you need: Ask user for data. Scanner class can help write data to file. See the PrintWriter class | |
Re: Can you give some examples of the type of expressions you are looking for. A technique for getting random operators would be to put them into an array and use a random number generator for selecting the operator. | |
Re: Reading the API doc for the method you are using should help you understand what it does. If you have questions about what it says, copy the text of the doc here and ask your questions. | |
Re: Is that your assignment that you just posted? | |
Re: Try debugging the code by printing out the values that control what is added to the order variable. Add lots of printlns statements. When using if/else if statements the first one that is true will be the ONLY one that is executed. Make sure the variables are tested in the … | |
Re: > Any suggested place to start? Post the full text of the error messages so we can see what the problems are. | |
Re: By "map" do you mean a background image that is drawn and filled in as it is moved? For example if the background is moved down, new background is drawn in on the top. | |
Re: > how to replace the proper "*" with the guessed letter Where are the "*"s for the letters in the word stored? If they are in a String like this: "****", you could use methods in the String class to get the substring before the letter to replace and the … | |
Re: > how i can test if it is checked You would use a syntax like this to call a check box's method: `referenceToCheckBox.methodThatSaysIfChecked()` an element in an array is a reference to an object and can be called the same way: `array[ix].aMethod()` See the API doc for the JCheckBox class … | |
Re: > Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException > at hospitalbilling.PatientAddress.searchInfo(PatientAddress.java:32) There is a variable on line 32 with a null value. | |
Re: > NullPointerException in Main Class.java:39 Look at line 39 in Main_Class and find the variable that has a null value. Then backtrack in the code to find out why that variable does not have a valid non-null value. | |
Re: Please post the full text of the error message. Note: Exceptions are thrown when the code is executed, not by the compiler. | |
Re: Can you explain what your problem is? Are you getting compiler errors? | |
Re: > when the if statement doesn't run my trail variable doesn't get incremented. Where do you assign any value to the trail variable inside the if statement? If you don't assign it a value its value does not change. Can you post the code's output and add some comments to … | |
Re: Are you asking how and when the OS and jvm send key pressed event data to your program? Try some debugging by adding a println to the keyReleased() method to see when it is called. | |
Re: > why the upper two lines of code produce error! Please post the full text of the error message. One problem is that your class has the same name as a Java SE class. Changing the name of your class should fix those errors. | |
Re: > how to distiguish if the user input was a string or a int. Several ways to use the Scanner class. It has methods that will test what the user has typed in before the program tries to read in the data. These methods all begin with these 3 letters: … | |
Re: Where is the println statement that prints out the null? What is the value of the roll variable that is returned by the roll() method? | |
Re: > I keep getting some errors Please copy the full text of the error messages and paste them here. > I feel like I am missing an else or some curly braces For curly braces, some IDEs have a "Find matching" feature. Put the curosr before one, press some keys … | |
Re: Have you written any test programs and added these code segments to them to see how they execute? Compile and execute the code to see what the results are. | |
Re: Can you iterate through the collection, test each object and put it in one of the new lists based on its value? | |
Re: > read from a file text Where in the code are you trying to read from a file? For simple text files the Scanner class could do it. > store the person data into an array list Where is the arraylist for the person data? | |
Re: Please post the code you are having problems with. | |
Re: > why my regionsareValid method won't work. Try debugging the code. One technique is to add println statements to print out the values of variables as there values are changed and used. Where in the faulty method does the test fail to find the invalid data? Add some printlns there … | |
Re: Please post the code that you have questions about here on the forum. | |
Re: > how would I make it so that the program keeps running and doesn't stop after 1 user input Put the code inside of a loop like a while loop. Stay in the loop until the all the user input has been read. Please edit your post and format the … | |
Re: > it still won't work. Can you explain what "won't work" means? If there are errors, copy and paste the full text here. If the results are wrong, copy and paste them here and explain what is wrong with them. To see what the code is doing add some println … | |
Re: > Having some trouble Please explain. What happens when you compile and execute the program? If there are any errors, please copy and paste the full text here. If the program executes, please copy the full contents of the command prompt window and paste it here. To copy the contents … | |
Re: > not sure why getting error Please copy the full text of the error message and paste here. | |
Re: Yes, you should be able to write a program with those options. I don't know if you can set the response type if that is an OS setting. | |
Re: Do you know how to start (invoke) a java program by entering a command line on a command prompt window? For example: java TheClass thearg "thearg" is passed in the String[] args array passed to the main() method. | |
Re: > do I need to create a new variable Try it and see what happens. You'll need a print statement for each variable. | |
Re: > a way for the all the methods that i have that ask for the user input need to go into the respective arrays Use a loop for each array that asks for the user's input, reads the input and stores it into the array. Is there any correspondence between … | |
Re: `array(1)="Section A"` That is not a valid method call. You can not assign a value to the call to a method. array(1) is a call to a method (the ()s) Do you mean to make an array reference? Then use []:`array[1]="Section A"` | |
Re: Can you put the images, etc in the jar file? Then they would always be at the same location. I use the jar command to add files to a jar file. | |
Re: One way I work out the sequence of steps a program takes is to start at the main() method and number each statement in the order it is executed. A simple start: public static void main (String[]args) { E e = new E(5); // 1 System.out.println(e.f(8,4,2)); }//main() public E(int z) … | |
Re: > have this array of string joe,DE2300,A sam,RM4901,B allay,SM9800, That doesn't look like an array. It looks like a String. To split that String up into separate Strings in an array look at the String class's split() method > want to split the array to another array What type of … | |
Re: There are two. One is passed in to the method and the other is the the class object that holds the method being executed. The call to the getX() method calls the local class's method for the value of x in the currrent object. |
The End.