318 Posted Topics
Re: [CODE] public class Class1{ } public class Class2 extends Class1{ //class 2 is a subclass of class1 } [/CODE] That is the basic syntax for inheritance in java. | |
Re: Post how you incorporated his code please. | |
Re: You are declaring the same variable from your processScore() method params in all your enhanced loops. You cannot do that. The enhanced for loop needs to have a type and variable declared locally. You read the loop as: (for each double in list) //do something It is not the same … | |
Hey, I have a question. I was writing a custom Array type class. In my template declaration I use the type name as DataType. I was making an attempt at creating an insert method, which takes a DataType argument and the index to insert at. I originally had this code: … | |
Re: The reason the RHS of your decimal point is so large is because a double is a precise type. So you need to format the output. I suggest using the getCurrencyInstance() method of the NumberFormat class which will return a currency format, then pass the value into that format. [CODE] … | |
Re: I would love to see the source you are pulling this from. You [B]cannot[/B] create a method [B]inside[/B] another method. [CODE] public class add { public static void main(String[] args) { int sum = add(5, 2); System.out.println("Sum is " + sum); [COLOR="Red"]public static int add(int firstInt, int secondInt) { return … | |
Re: 1. You have not created a constructor. 2. Why do you have a display method with the parameters your assignment spec said should be [I]inside [/I]the constructor? 3. Your spec says you need to create an array of objects, which in this case will be TVshow objects, not an array … | |
Re: As masijade said, look at your constructors. You cannot have multiple constructors [B]with the same parameters[/B], which in this case, is no parameters. And you also wrote your run method [B]inside[/B] the constructor. You [B]cannot[/B] write a method [B]inside[/B] another method. | |
Re: In your printf expression, your format specifier is a float, try changing &f to &d. [url]http://sharkysoft.com/archive/printf/docs/javadocs/lava/clib/stdio/doc-files/specification.htm[/url] | |
Re: But why would you want to do that? It takes away the point of object programming. You would just be setting a name to a variable, instead of the name of an employee, which doesn't really make much sense. edit: Say you create 2 employees [CODE]Employee jim = new Employee(...blah...); … | |
| |
Re: You must be getting an error. [CODE] while()(!(correctInputCheckChar == 'y' || correctInputCheckChar == 'Y'));[/CODE] Is not valid. | |
Re: Such an epic'ly bad attempt at coaxing us to do your homework. | |
Re: Funny how urgency causes laziness. Doesn't make much sense does it? | |
Re: Think what you are trying to do. [CODE]Rectangle box = box.translate(40,30);[/CODE] the variable box is of type Rectangle. As javaAddict pointed out, the translate method returns void. This line is basically like saying: [CODE]int i = ;[/CODE] Therefore, void methods are called independently. Meaning, you do not need to store … | |
Re: There is no way to align System.out.print's. You will just have to use the \t,\n etc..to achieve your desired result. e.g. [CODE]System.out.print("Name\tAge\tAddress\n"); System.out.println("James\t20\tSandyHouse"); [/CODE] | |
Re: What part are you having a hard time with? Programming concepts? Logic? | |
Re: You would need a JFrame and a JComponent and some type of paint method. [url]http://java.sun.com/products/jfc/tsc/articles/painting/[/url] | |
Re: Post your code using CODE tags. You also have not told us your problem. Do you have any parts working? Which part/parts are you having trouble with? Are there any compile errors? | |
Re: As naief pointed out, You have not specified the type of variable RectangleBox is. Every variable needs a type. [CODE] //type - variable name int a; double b; Rectangle rect;[/CODE] In your case, you want your RectangleBox variable to be of type Rectangle. Most naming conventions don't start variable names … | |
Re: I don't think you fully understand objects. An object is an instance of a class. So, say you have a class named Monster, as stated above. You only ever have that 1 class, but you can create infinite number of objects(instances) of that class. [CODE]Monster mon1 = new Monster(); //mon1 … | |
![]() | Re: [B]B[/B] [I]Brackets first[/I] [B]O[/B] [I]Orders (ie Powers and Square Roots, etc.)[/I] [B]DM[/B] [I]Division and Multiplication (left-to-right)[/I] [B]AS[/B] [I]Addition and Subtraction (left-to-right)[/I] Split your calculations using this order of operations |
Re: Create a method in the class that uses JFrame that returns the value of x. [CODE]public int getX() { return x; }[/CODE] Then just called that method from your JPanel class.(I assume you know how to do that) | |
Re: What are you doing to try and end the loop? | |
Re: [QUOTE=AaronLLF;1450219]Nevermind... fixed it right after posting. Epic. Fail.[/QUOTE] Ok, but wouldn't it have been a better idea to keep your problem posted, and then post the solution you found? What if you were searching google for "basic 2d physics +java" and you saw this post advertised, would you not get … | |
Re: add a Panel to the frame and draw the background on that. You shouldn't really be drawing directly onto the Frame anyway. But, if you want to, I would say you will need to use the getContentPane() method. | |
Re: Add a println inside where you add to the arraylist, to make sure it is actually adding, print out the list also at this point. | |
Re: sLength, sWidth and sDepth are Strings. You cannot multiply strings. To convert a String that contains a number, to an int/double etc.. You must parse it. [CODE]int sWidth = Integer.parseInt(width.getText());[/CODE] Try that. | |
Re: wait, so what happens when you press the space bar one time? | |
Re: Why have you not implemented Runnable on any of the classes you are trying to run threads in? [CODE] public class TimerClass implements Runnable {[/CODE] [CODE]public class MouseGameV2 extends JFrame implements MouseMotionListener,Runnable { [/CODE] | |
Re: Why are you using recursion? It is not needed if you only print out 1 number. All you do is create your power method, then return Math.pow(x,n). You ask for a number, then ask for the exponent, there is no recursion needed. As was stated, you test the value of … | |
Re: So you want someone to do your homework for you? If you had read the [B]rules[/B] you would see that nobody will do your homework for you for less than $50 | |
Re: If you do not know which IDE to use, it means you are just starting off. If you are just starting off you shouldn't use an IDE(and even worse use it for GUI dev) If you did make said gui with an IDE, and you are a beginner, you will … | |
![]() | Re: [QUOTE=ovidiu_b13;1447110]I've started reading a fiew books and sites, to learn something. Can you give me an idea to start working on?[/QUOTE] Idea: You have a list, why not use that list to base your study off? Just google this list with +java in the search. 1. Classes - Objects 2. … |
Re: Please tell us the names and lines of the 2 textboxes and also the default value it places i.e. where you declare and initialise them. You can probably search it in your ide | |
Re: Instead of using inline code, create an if block using the {} braces. [CODE] if(prime % chk == 0) { prime++; chk++; } [/CODE] This is the extreme basics. Java,C#,C++ and many other languages(if not all) use code blocks. | |
Re: Like you I'm not too sure about the technical side, but I know for a fact this isn't the first time someone has thought of this idea. I remember playing Duke Nukem 3D..before MMOs were popular(or even that known) and I thought how good it would be to make a … | |
Re: [QUOTE=Anirudh.;1447406] PS:you are supposed to make use of scanner class[/QUOTE] Oh are we now? I'm glad you told me that, I was just about to write your program without it! Show your attempt. | |
Re: Unfortunately, you will have to code it like any other frame. | |
Re: Ok, so you need a method that takes 2 double as paramaters, and returns a double. Then just calculate the hypotenuse using the formula you should have learned in primary school if you weren't one of those students who got other people to do their homework...oh wait. Post your attempt … | |
Re: Oh wow, I was hoping the poll was a yes or no option.... | |
Re: If you want to have a frame inside a frame: [url]http://download.oracle.com/javase/tutorial/uiswing/components/internalframe.html[/url] Otherwise: Is the frame being hidden under the other frame? Try offsetting the position of the frame on the screen. | |
Re: As bibiki pointed out, there is no scope resolution operator in java. If you are not in the wrong section, and you are actually talking about java, Then the reason you cannot call not-static methods/variables using [CODE]Object.variable1 ..etc[/CODE] Is because non-static variables/methods are Instance variables/methods. Meaning, they can only be … | |
Re: You need to use + when concatenating parts of a String. [CODE]System.out.println("\n" + var1+"\n" + var2);[/CODE] You had a , instead of a + | |
Re: What is EasyIn? Is this your own class? It is not a java class. Normally, people use the Scanner class to take input. [CODE] Scanner input = new Scanner(System.in); n1 = input.nextInt();[/CODE] | |
Re: You do not re-enter your judging loop, because judgecounter is never <= 5 again, After you increment your competitor counter, reset judgeCounter. [CODE]competitorCounter += 1; //increment competitor counter by 1 judgeCounter=1;[/CODE] Too fast for me gerard!:'( that damn indentation bled my eyes and I had to take a break! | |
Re: Or if you have a class that contains all your custom components and you want to add these to your current container. Make them all static, and then: [CODE] add(MyClass.button1) [/CODE] | |
Re: Have you imported java.util.Arrays? Which version of java are you compiling with? | |
Re: For your output error, I assume it's because you are calling cin.ignore() before you take input. afaik you should do this after input, to flush the input stream. |
The End.