2,777 Posted Topics
Re: [QUOTE]program that outputs the probability of n amount of coin tosses[/QUOTE] What does your program output now? If you want it to output something different, please explain and show what you want. | |
Re: Can you explain what your problem is? Do you get errors or is the output wrong? Post the output with your questions or comments and show what it should output. Comments on your coding style: Don't have statements on the same line following a { Put the statement on the … | |
Re: [QUOTE] if I return Distance it still mark at compiler error. [/QUOTE] You forgot to post the error message. Also you need to show the code that causes the error. [QUOTE]What should I return here?[/QUOTE] The method says it returns a Distance object. Do you want to return the current … ![]() | |
Re: First suggestion would be to change to using Swing components vs AWT. Change the Frame to JFrame. Instead of trying to change this program, I'd suggest you start with a new program and build the GUI from the beginning as per your instructions. When you get the GUI laid out, … | |
Re: That code works for me. Can you post the code that didn't work. | |
Re: It executes for me: [CODE] Scanner my_scanner = new Scanner("www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc").useDelimiter("[[|]]"); System.out.println(my_scanner.next()); //==> www.exampledomain.com/abc/[[FLAG1]]/abc_[[FLAG2]]gfc [/CODE] | |
Re: I don't know why you get that error. Are you using an IDE? You should be getting a NPE because a variable at that line does not have a value. | |
Re: Check for correctly pairing of { with } You need to properly format your code so you can see the pairings of the { and } The line with the ending } should start vertically below the line with the starting { All lines between them should be indented 3-4 … | |
Re: Does the code compile and execute? If not, please copy and paste the error messages here. How does your code choose a word? The while loop will read to the end of the file. | |
Re: If you are not sure what the results of your conditions, print them all out and see what they return. For example: System.out.println("(year % 4 == 0)=" + (year % 4 == 0)); Do that for all the conditions and you should see where the problem is. | |
Re: How do you get the value to be reversed? As a String? Or as an integer? | |
Re: [QUOTE] their messages like "YOU WON!!" and "GAME OVER!!" do not show up[/QUOTE] I just ran the code and did get the message "YOU WON". Better do some debugging to see why you don't. | |
Re: What happened to your earlier post of this problem? Where is the code to test the methods? The main method looks empty. The code you posted does NOT compile. | |
Re: What does the current code do? What is wrong with the results? Show the output and explain/show what it should be. | |
![]() | Re: Action listeners are put in a list and, I assume, are called based on their order in the list. Can you put them in the list (ie add them) in the order you want them called? Does the component have methods for getting to the list of listeners that would … |
Re: What is the problem? Do you get errors? Is the output wrong? Please post the output to show what is wrong. What is the purpose of the variable b? | |
Re: charAt is a method in the String class. It is used to get a single character from a String. | |
Re: The method is to print the String and pad it with spaces(?) or truncate it to width? Where are the words you talk about? Is the method to parse the String and split it at the white spaces to produce words? Can you give several examples of what you what … | |
Re: Since java has this error: Null[B]Pointer[/B]Exception, I assume that is has pointers. The question is what is the behavior of java pointers and how can you use them. They have very little in common with c pointers. | |
Re: What does it take to compile and execute this program? | |
Re: [QUOTE] Drawing in applets is almost always done with double-buffering. This means that drawing is first done to an offscreen image, and when all is done, the offscreen image is drawn on the screen. [/QUOTE] From your link. Have you tried copying the ideas that are shown on that site? | |
Re: [QUOTE]I am unable to enter more than 1 television show.[/QUOTE] What happens after the first show is entered? The code looks like it is in a loop and should continue. Add a println to show the value of d inside of the loop as the loop goes around. | |
Re: [QUOTE] fires off the jar[/QUOTE] Can you explain what "firing" a jar means? A jar contains files that could include java class files one of which could have a main method. | |
Re: What do you define as "Security Testing"? Can you give some examples? | |
Re: [QUOTE] it does print out what I expect[/QUOTE] Can you show what is printed out and show what you expect or want to be printed out? | |
Re: For debugging To see if there is anything in the file, print out the File's length. | |
Re: Yes void is OK for a method return type. Use it when the method does not return anything. Do you get any error messages when you compile the code? The names of your methods are misleading. A method beginning with get should return a value and not be void. Before … | |
Re: Is the definition for the Chatclient class on the classpath so the compiler can find it? | |
Re: [QUOTE] Is there any mechanism to read a specific object from a file? I[/QUOTE] I think you have to read the file sequentially from the beginning. If the file has more than one object then you will need to read the ones before the desired object to get to the … | |
Re: [QUOTE] how to upload a file to a folder[/QUOTE] I assume that the file is on your PC and the folder is on a server. If that what you have, then you need some code on the server that you can give the file to and tell it where you … | |
Re: Does the code compile and execute and give you the correct results? One shortcut would be to return the boolean results of this expression: (x==y) directly vs using an if/else statement. (x==y) gives a boolean result of true or false. No need to test it, just return it. See what … | |
Re: Is this your homework assignment? Do you have specific questions about how to do your assignment? Do you have any code you are having problems with? Post them here. [CODE]public class IMultiSet{[/CODE] This looks like a class definition not an interface. | |
Re: [QUOTE]How to implement the (20.0%) and the (9.0%) in the Deductions area[/QUOTE] Do you have the formula for computing those values? | |
Re: [QUOTE]way of coding list in permutation.[/QUOTE] Can you explain what you want the code to do? | |
Re: What do you need help with? The Scanner class will be useful with reading the file. The String class has methods for comparing Strings. The ArrayList class can hold Strings that need to be saved for later. | |
Re: [QUOTE]it shows errors i need help to clean it[/QUOTE] Please post the FULL text of your error messages here. | |
Re: Is the value of the variable: is null? Print out the value of path to see what file it is looking for and check if that file exists. Are the files on the classpath? Check the API doc for the method getResourceAsStream | |
Re: [QUOTE]way to make it run by just double clicking the jar[/QUOTE] Most java installations on Windows add an entry to the OS's file association table to open a jar file with the correct command line so when you double click on the the jar file the command is executed with … | |
Re: [QUOTE] i need experts to kindly help me out.[/QUOTE] Can you explain what your problem is? | |
Re: Sounds like an advanced topic for a beginner. Look at the JTextxxxx classes for the possibility for displaying text and allowing the user to enter text on the same area as the displayed text. I'm not sure how to make some area's R/O to restrict the user's input. | |
Re: Many java programs are distributed in .jar files. Installing a JRE should set your OS to call the java program when you try to open a jar file. | |
Re: Please post the FULL text of the error message. To copy the contents of the command prompt window: Click on Icon in upper left corner Select Edit Select 'Select All' - The selection will show Click in upper left again Select Edit and click 'Copy' Paste here. Also show the … | |
Re: Cross posted at [url]http://www.java-forums.org/new-java/48227-code-calculate-mode-using-array.html#post232571[/url] | |
Re: What is there about the output that makes you think you need a nested loop? You can generate that print out with a single call to println by using \n characters to put the next String on the next line. | |
Re: Scanner methods can be tricky. The Scanner buffers input and can block waiting for input. Or it can save a newline and return it to the nextLine call. For example if you enter: A word to the wise <PRESS ENTER> and use next() only "A" is read, and "word to … | |
Re: [QUOTE]NoClassDefFoundError: Applet/Main (wrong name: Main)[/QUOTE] The error says that the code= tag value does not match the class name Please post your html. What is the full classname including package of your applet? | |
Re: [QUOTE] want to add 1 to the name each time the user says yes and create a new object:[/QUOTE] You can't create new variable names when executing a program. Names are defined when you type them in. There are other ways to have "collections" of objects. For example save the … | |
Re: That was a mistake adding to the above's rep. I was trying to decrement it. | |
Re: [QUOTE] it doesn't read my text file into my array[/QUOTE] What do you do with the data you read from the text file? Your first while loop will read ALL of the tokens into the one variable. To see what is happening add a println in the loop to show … | |
Re: You've got a lot of the code for the program but I see you are missing the code that does the find. You would need to read in the search argument from the user and then loop through all the entries in the arraylist and compare what the user entered … |
The End.