Search:

Type: Posts; User: Cornix

Page 1 of 20 1 2 3 4

Search: Search took 0.54 seconds.

  1. Re: Are the arguments of a method part of the method's unique identity?

    Methods have a signature. The signature is the name and the parameter list of the method. There can not be 2 methods with the same signature in a class. There may be any number of methods with the...
  2. Replies
    3
    Views
    39

    Re: For loop optimization

    BigInteger is the way to represent large numbers. Thats what it is good for. But there is no way to do it fast.

    Computers are very limited when it comes to numbers. You have to draw a line at some...
  3. Re: Best Way of Doing This Complex Multithreading Situation

    The question I would ask is this: How often will it happen, that your "Master-Thread" will be put to sleep and how often will it have to wake up?
    If you expect constant usage I would simply kill the...
  4. Replies
    3
    Views
    39

    Re: For loop optimization

    BigInteger are in general very slow. Much slower then regular primitive data types. There is not much you can do, personal computers are just not meant to work with too big numbers.

    Of course if...
  5. Replies
    17
    Views
    139

    Re: Super Beginner Instructables Project help

    A simple internet search can solve your problem easily.
  6. Replies
    17
    Views
    139

    Re: Super Beginner Instructables Project help

    Looks like you need to import the referenced libraries (and have them on your classpath when you try to compile) and as Norm already said, you never define a class. All code in java must be within a...
  7. [SOLVED] Re: Server doesn't work with more than one connection

    You use multiple threads but you do absolutely no synchronization. This is obviously going to fail.
    Whenever there are several threads using the same data (in your case your client list "al" for...
  8. Thread: Swing-Singleton

    by Cornix
    Replies
    13
    Views
    167

    Re: Swing-Singleton

    There is really NOTHING you can do to prevent the user from starting the application in a second JVM. This only depends on the way the application is started.
    How do you start your application? From...
  9. Replies
    6
    Views
    109

    Re: Trouble with ObjectInput/OutputStreams

    Observers and Listeners are the same thing. You were talking about Listeners in the OP and that was what I was referring to as Observers. In general, as I said, they are NOT a good solution for...
  10. Re: Beginner, need help learning Java from Python

    I am sorry but your code does not make any sense.

    for (int i = -1; (i = src.indexOf(query, i + 1)) != -1; ) {
    You first set i to be -1 but then you immediately give it a different value, the...
  11. Replies
    6
    Views
    109

    Re: Trouble with ObjectInput/OutputStreams

    Observer patterns usually dont work in multi-threaded enviroments, at least not when done by beginners.
    The common misconception is that the code of the observer is run on the same thread that...
  12. Thread: Swing-Singleton

    by Cornix
    Replies
    13
    Views
    167

    Re: Swing-Singleton

    I dont know how your third party tool works. But if it really starts a second JVM then your singleton approach is not going to work. Static variables are not shared across JVM instances, they are...
  13. Thread: Swing-Singleton

    by Cornix
    Replies
    13
    Views
    167

    Re: Swing-Singleton

    What you are talking about is the JRE (runtime enviroment) which, by the way, is in your case very outdated. What I mean is a virtual machine, the sandbox in which a Java program is executed.
    Each...
  14. Thread: Swing-Singleton

    by Cornix
    Replies
    13
    Views
    167

    Re: Swing-Singleton

    Static variables are only global within the same JVM and ClassLoader. If you start your application in a different JVM it will become very hard for you to enforce your singleton design.
    One way (a...
  15. Thread: Inexcusable !

    by Cornix
    Replies
    3
    Views
    86

    Re: Inexcusable !

    Works for me:

    public class AnnotationTest {

    public static final String TEST = "unchecked";

    @SuppressWarnings(TEST)

    }
    I guess you are doing something else wrong.
  16. Replies
    4
    Views
    89

    Re: Abstract Class with non abstract method

    You can only access methods of objects (instances) so before you can access any method you need to have an object (instantiate a class).
    You dont instantiate the abstract class (since that is...
  17. Replies
    4
    Views
    89

    Re: Abstract Class with non abstract method

    The same way you would access a non abstract method in a non abstract class.
  18. Re: How could I add a menu to my (first) Java game?

    There is no simple answer because the question is vague. If you want to do it I would recommend:
    1) You find out what a menu is (in terms of code)
    2) You learn how swing works
    3) You use your...
  19. Re: I have a bit of a design question about 4 methods common to 2 classes.

    Do an internet search for delegation. This will probably help you with your problem.
  20. Re: Output on practice example from book not quite right

    I am not 100% sure if double is platform dependent in java or if this has changed between versions of java.
    As a general rule of thumb: Anything that has a floating point is inaccurate in any...
  21. Replies
    32
    Views
    307

    Re: JLabel not updating

    1) You dont have to call repaint() manually. When you set the text of a JLabel repaint() will be called for you.

    2) What thread is your code running on? All Swing code MUST be executed from the...
  22. Re: How to safely remove object from collection in multi threading

    Well then obviously you have to build your application in a way that no object that is currently being used will be removed from the list. Perhaps by joining the threads to make sure they are all...
  23. Re: How to safely remove object from collection in multi threading

    If you use a synchronized list then it is supposed to work in a multi-threaded enviroment. Perhaps you are not using the synchronized list correctly.
  24. Replies
    8
    Views
    259

    Re: A more acceptable way of writing to files

    Looks much better. You are now using the try-with-resource block correctly.
  25. Replies
    8
    Views
    259

    Re: A more acceptable way of writing to files

    Now you are using a try-catch (thats better) but not a try-with-resource which is the recommended way.

    The try-with-resource looks somewhat like this:


    try (FileOutputStream fos = ...) {
    ...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4