4,084 Posted Topics
Re: if your final is tomorrow, you should have understood this by now. all your questions are very, VERY, basic knowledge. I have no doubt you can find the answers to all of them in your cours notes. if you are taking a course which takes more than 1 hour a … ![]() | |
Re: [Code=Java] for (int x = 0; x < StArray.length; x++) { Name = JOptionPane.showInputDialog("Enter First and Last Name:"); StudentID = JOptionPane.showInputDialog("Enter StudentID"); Address = JOptionPane.showInputDialog("Enter Adress"); Student[] Object = new Student[x]; StArray[x] = Object[x]; System.out.println(Object[x]); } [/Code] you have some logical mistakes here: 1. you shouldn't use 'Object' as the … | |
Re: can you provide us with the full error messages? either you 've not given us all of your code, or you're also having trouble with the lines [Code=Java] list List1 = new list(); ... IntSLLNode t; [/Code] | |
Re: what do you mean by 'between numbers'? on the same line? on a separate line? what is your input, what is your output and what exactly is the output you expect? | |
Re: what you're doing wrong? you're trying to cast a JButton to a JPasswordField [Quote="Error message"]Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: javax.swing.JButton cannot be cast to javax.swing.JPasswordField[/Quote] I assume what you are trying to do is, validate the info in your JPasswordField? in that case: you'll need to have a JPasswordField (let's … | |
Re: well ... what you are describing is not the output of running the code you've posted. in the code you've posted, when you start your application, you'll see the text "the doctor is in" when you press any button, you clear that text without setting a new value visible. | |
Re: NO effort from your side, NO help from ours. you say you didn't copy the code of your prof, well ... as far as we know, you didn't get any code, and are supposed to write it yourself. if it is code your prof handed you to help you, no … | |
Re: and as for the white spaces: remove all the spaces (off course after you've made copies of the original values, if you still need them later on) | |
Re: what class is data an instance of? I assume it is the Scanner class? remember, you're Scanner is trying to read a boolean, while you're having your user enter an integer. (don't really use Scanner myself, but this might be the issue.) try with: [Code=Java] boolean mail_List = false; if … ![]() | |
Re: let's start here: [Code=Java] int[] mainArray = {}; [/Code] you say that mainArray is an array without elements, and later on, you try to store information in the array for indexes it doesn't have. an option would be: [Code=Java] int[] mainArray; int y = getNumberOfElementsForArray(); mainArray = new int[y]; [/Code] … | |
Re: I assume this is because in your for loops, you always start with 0. try by starting them with 1 | |
Re: if your exam is about to arrive, I doubt this is the first time you've had the option to study this material. realise that an int is (normally portrayed as) decimal, that what you want is hexadecimal, take a look at the differences and see if you can find the … | |
Re: [QUOTE=Samith Dilhara;1711496]Suppose the xMethod() is invoked in the following constructor in a class, xMethod() is _________ in the class. public MyClass() { xMethod(); } A. a static method B. an instance method C. a static method or an instance method what is the answer a or b or c[/QUOTE] the … | |
Re: or, don't save the length, since you're not really using it: save the name with the greatest length so far when you enter a new name: [Code=Java] //... counter++; if ( input.length() > storedName.length()) storedName = input; //... [/Code] | |
Re: the code worked fine but: [Code=Java] while(!word.equalsIgnoreCase(termination)); [/Code] he should just have removed the ';' there. | |
Re: this is a Java forum, not a JavaScript forum (no, they are not the same) and to answer your question: yes, there is, and even if I'm mistaken and it's not a standard validation, it's not that hard to write. | |
Re: NormR1 is repeating "Main class" for a reason. You don't want a Main class. You don't need a Main class. As he already told you, you need to implement a main method (and yes, there is a big difference). no matter what course you are taking, or what book you … | |
Re: what questions? every question you have is answered in the book Cleo123 referred to. SCJP (or OCPJP) is about the basics of Java language, it goes deeper into basic stuff that can happen every day. it gives you better insight into what happens when you compile, run , ... your … | |
Re: > try this...this syntax might not be the answers that your expecting.... public class qwe { public static void main(String []args) { int array []= {1,2,4}; for( int x = 0; x < array.length; x++) { System.out.println(array[x]); } } } > end quote. This was exactly the issue, NewbieGuy, but … | |
Re: re-check every { and } for instance: why do you open a bracket on the next line [Code] if(!world.multiplayerWorld) { world.entityJoinedWorld(new EntityRocketLAW(world, entityplayer)); ++timesshot; [B]{[/B] itemstack.damageItem(6, entityplayer); return itemstack; [/Code] I think you'll find you didn't close all your blocks that you open with a '{'. | |
Re: depends on what you want and what you need. there are lots of frameworks out there, but what do you want them to do for you: handle your front-end, back-end, ... | |
Re: also: re-think your expressions and tests for your while loop. just think about it, how many times will your [Code=Java] while(true){ //... } [/Code] run? | |
Re: try adding File temp = new File("filename.txt"); System.out.println(temp.getAbsolutePath()); if you create a FileInputStream, your vm will automatically assume the file already exists, while when using a File object, you can first verify and create one if necessary. | |
Re: you are calling the method getInt() from the class EasyIn. unless you have written a class EasyIn, that class does (as far as I know) not exist. if you did make it, you need to import it. or, you could use the [URL="http://docs.oracle.com/javase/6/docs/api/java/util/Scanner.html"]Scanner[/URL] class instead. | |
Re: ever tried asking the almighty [URL="http://www.lmgtfy.com/?q=UML+%2B+inheritance"]Google[/URL]? how do you think it is represented? | |
Re: to add an object to (for instance) ArrayList<YourType> list = new ArrayList<YourType>(); the object you want to add has to pass the "is-a-YourType" it's not that difficult to do that, but the compiler will not allow any that don't pass this test to be added, so reading up on Generics … | |
Re: a 'little' old? you do have a talent for understatement, don't you? not only old, also bit ... sneaky. as far as I can tell, by looking at the previous posts, what he wanted to do, was "borrow" (propably his choice of words) or "steal" (the legal definition) contents of … | |
Re: so, we must assume he did not give 'X' as input. even worse, we can assume that the code he is showing us is not the code he was running when he got the exception. he get's an exception thrown for a line of code somewhere in his instance methods … | |
Re: you mean: can we re-write it for you in OO-design? sure we can, but we won't. what you've done so far, is copy pasting your assignment here, and hoping we will do your work for you. step 1: decide on which objects you'll need step 2: implement the methods you … | |
Re: while(true) will always be true, so it will never leave the loop, unless you add a break statement, or change expression you are testing on | |
Re: well, it's telling you on which line you are using a variable that you haven't instantiated yet. add a print right before it, so you can check which var it is, or add default values to your variables, that should help you out. | |
Re: add the weight of each person to weights, and verify if the capacity of the elevator can take the extra weight before going over it's maximum. | |
Re: ehm ... you don't need to put an entire class somewhere to be able to use it. you can always instantiate it and use the instance, just like you do it now in your main method in that class | |
Re: what error is thrown? what is the complete code? you're not giving us a lot to work with | |
Re: 1. implement all the methods of ActionListener you should implement 2. what belongs in one class, put it in one class 3. don't use a 'course' variable without declaring one if you just try and compile, your compiler will give you a list of errors it encounters, that can also … | |
Re: orrrr ... you could check out the .equals .before .after methods :) | |
Re: what do you mean 'put them together' and which mistakes are you referring to? is the code not doing what you expect it to do? | |
Re: by writing the code. all I see is your assignment, what are you having trouble with exactly? | |
Re: [URL="http://docs.oracle.com/javase/6/docs/api/java/lang/UnsatisfiedLinkError.html"]explanation[/URL] possible solution: add a try-catch block | |
Re: ehmmm.... no. just [Code=Java] combobox1.getSelectedItem(); [/Code] getItemSelected() is not (as far as I know, anyway) an existing method and you can not let a method be followed immediately by a new String like you do in your last post. | |
Re: you start with a string the charAt method will return the char on the index you provide in the string you apply it to. IgnoreCase() => this can occur in equalsIgnoreCase(), a method that you can find in the String class. just run the next piece of code, and you'll … | |
Re: seriously.. this is not Developers-for-Rent as you said yourself, it's a simple question, so I have no doubt you'll be able to solve it yourself, or, at least, produce a bit more code than you've shown us so far. | |
Re: @cbrolly21 ... serious.. the last post here was in april 2005 ... not to mention the facts that a. what you suggested here, has already been suggested before b. the OP already said his problem was solved so ... how exactly does this post contribute to the thread? ![]() | |
Re: well ... no offence, but you've made a mess out of your usage of {'s and }'s. starting from line 108. not to mention the fact that you're using variables you didn't declare or initialize. you may want to spend some minutes cleaning your code. | |
Re: and remember: [Code=Java] if (bet == "high") { rollTotal = total; } else if (bet == "low") { } else if (bet == "seven") { } [/Code] is a big NO-NO. never compare objects with the == comparator, always use the .equals method. | |
Re: what is it doing wrong? as far as I see from your code, what you're doing wrong is that you don't compare max and adding to number times occurences within your loop. | |
Re: WHY do you think it is wrong? WHY are you unsure about those methods? what do you expect as output? | |
![]() | Re: [Code=Java] if (minScore > scores[i]); [/Code] remove the ; an if (just like a lot of other 'blocks') can be given a scope in two ways: either you put the code between { /*enter code here */} OR the 'block' ends at the first ; ![]() |
The End.