Search:

Type: Posts; User: helloworld922

Page 1 of 20 1 2 3 4

Search: Search took 0.13 seconds.

  1. Replies
    2
    Views
    937

    [SOLVED] Re: Strict Polymorphism

    Simply put that's not possible.
  2. Replies
    4
    Views
    1,021

    Re: Casting Confusion

    Hmm... interesting. I thought that would get rid of the error, but doing some testing it seems that's not the case. Yes, it is a runtime check but I seem to remember there being some "code structure"...
  3. Replies
    4
    Views
    1,021

    Re: Casting Confusion

    You can use instanceof to check the type.



    if(o instanceof ArrayList<String>)
    {
    ArrayList<String> l = (ArrayList<String>) o;
    }
  4. Replies
    9
    Views
    946

    Re: What is best loop sequence?

    Presumably the vehicle.Company can't be both G and F? It makes more sense to use an if-elseif type control flow, or even just an if-else if there can't be any other values for Company. This makes...
  5. Re: Commenting your code: RIGHT or WRONG way?

    So my development process actually starts with comments. I begin by describing what it is I need to do and roughly how it should get done. Filling in the actual code comes second.

    Adding extra...
  6. Replies
    5
    Views
    1,772

    Re: If you had a chess-like boardgame....

    It seems like you are trying to provide several distinct actions in a single method. Checking where a unit can move should probably be a distinct method from actually moving the unit. Both of these...
  7. Re: Java 2D Game: Implementing Simultaneous Keystrokes

    It sounds like you are running into a hardware limitation of your keyboard, not a software one. There is no possible software fix, the only option is to use a different keyboard.

    Further reading:...
  8. Re: My program always gives me an output of 0.0, what's wrong with it?

    Check the order of your commands. Java executes top-down in a block.
  9. Replies
    8
    Views
    1,231

    Re: BEGINNER! use of {} and ;

    curly braces in Java are used to denote blocks. Semi-colons are used to denote the end of a single statement. A for loop has syntax like this:



    for(initialize; condition; increment)
    ...
  10. [SOLVED] Re: The meaning of the characters "?" & ":" in for loops

    Yes, those are operators. They are not specific to for loops (as PhHein said).

    The two combined form a ternary operator (i.e. 3 parameters).


    a ? b : c

    How to read this:

    If a is true,...
  11. [SOLVED] Re: What will the compiler remove from the code?

    When in doubt, run your code through a dissassembler. The Oracle JDK includes a javap tool which allows you to decompile the output.

    I copied your code into test.java (default compiler options,...
  12. Replies
    5
    Views
    1,306

    Re: An easy question

    An anonymous class is just like a regular class, except it has no name. That means you can never refer to the type.


    new BaseType(base_parameters){
    // pretty much everything you can put into...
  13. Replies
    5
    Views
    1,306

    Re: An easy question

    You are creating an object of an anonymous class, which extends/implements javax.mail.Authenticator (depends on if javax.mail.Authenticator is a class or an interface).
  14. Re: determine the 1,000,000 th primitive number in less than 10 min !!!

    I have a few posts about implementing the sieve of Eratosthenes efficiently:

    Optimizing the Sieve of Eratosthenes

    One problem using the raw sieving technique is that the sieve asks the question...
  15. Replies
    3
    Views
    1,232

    Re: Need Help PLS

    @javaiscool Please don't spoonfeed answers. Please read: The problem with Spoon Feeding
  16. Re: Is it possible to achieve the encapsulation without class

    In Java 8 there are plans to implement Lambda expressions/Closures. I haven't read through the details on how these features will work in Java specifically, but in other languages with closures these...
  17. Re: can't create checksum algorithm/ can't understand concept of checksum

    There are many different ways to implement a checksum. See: Wikipedia: List of Checksums.
  18. Replies
    2
    Views
    1,189

    Re: Question about math.pow

    The output I get is exactly 4. What is the exact code you're using? Perhaps there are computations which result either parameter to "about 2", which would throw the result off.
  19. [SOLVED] Re: Trying to rewrite the main method to use as few lines of code as possible

    Yes, don't store the result into s and just use it directly. I wouldn't suggest doing this in practice, though as your line will become way too long and unreadable.
  20. [SOLVED] Re: Trying to rewrite the main method to use as few lines of code as possible

    It's silly to try and write as few lines as possible because Java code doesn't really care about the concept of "lines": you can put everything into one line and barring line comments, have it work...
  21. Replies
    8
    Views
    1,360

    Re: Where is my .class?

    Declare your classes as public.
  22. Replies
    6
    Views
    1,862

    Re: .toString method question!

    We can't read your mind or see what is on your computer screen. You have to post enough information here for us to be able to help you. What code you you have so far, what is it doing (exactly), and...
  23. Replies
    6
    Views
    1,862

    Re: .toString method question!

    What is the error message? Please copy/paste it here in its entirety.
  24. Replies
    2
    Views
    1,034

    Re: problem with inheritance

    Static methods aren't polymorphic. Which static method is invoked is determined by: 1. The type of the variable being used (note that the variable type is not necessarily the same as the type of the...
  25. Re: Big O notation... can you check my answers for each code segment?

    The reasoning for 1 is a bit convoluted. It is O(n) because you are running it half the time: O(n/2). But big-O drops the constant factors, so we're left with O(n)

    #5 is not O(n^2). O(n^3) isn't a...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4