• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in OOP Text Based Java Game

    Hve a look at other adventure games on the web and copy any ideas that appeal to you.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Probability and Coin Tossing

    I don't think I had that particular bug in my code anyway, and here are my reuslts for 1000 trials of each false,false,false vs true,false,false = 120 vs 122 true,false,false …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Probability and Coin Tossing

    Being deeply sceptical about this, and agreeing with Teme64, I hacked together a little Java version of the logic (no GUI needed), ran 10000 iterations with all 8 possible "A" …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in OOP Text Based Java Game

    You start by chosing a game! If you can't think of one then try searching the web.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java Lottery Program - Array

    Hi Adnan I suspect the reason why you have no replies yet is that the problem specification seems odd. Step 4 says "compare the elements using a loop", but you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in BSP Dungeon Generation in Java for Dungeon Crawler

    `return rand.nextInt((max - min) + min);` is the same as ` return rand.nextInt(max );` did you mean this? `return rand.nextInt(max - min) + min;` ps: Are you writing too much …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in BSP Dungeon Generation in Java for Dungeon Crawler

    I think you are wrong about randomHelper. It's crazy to ignore a known problem while looking for an unknown one. Track down and fix that problem before moving on. Maybe …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in My brother set his iPhone back to 1970

    Apparently you can keep it switched on until the battery is completely flat.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    The join is pointless when it's always called on the current thread, do just delete it. If it's possible that the close method could be called on a different thread, …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    I'm guessing that requestClose sets safeCloseRequeseted then the main loop exits? In which case you do have the thread problem I described above.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    Ps one way to call System.exit is to use exit on close on your JFrame - that would close your app without the join deadlock ever being resolved.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    It looks to me like the main loop runs in a new Thread (projectDCThread), and you call stop() from that, so when stop() calls join, it's calling it on the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    Simply exiting a loop won't terminate a program! We need more info. Why does the program exit after that loop - is the loop running on the only non-daemon thread? …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    Let me guess ... Do you exit your program via a System.exit(0) before projecDCThread has died?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Thread.join() doesn't fire finally block?

    When you execute the join your thread. Is suspended, so the finally is not executed then. When projectDCThread dies execution of your code will continue and the finally should be …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Can anyone tell me use of goto(x,y) in java (eclipse) ???

    Maybe he is, but that's a guess based on zero evidence. OP says nothing to indicate that particular use of a goto method. A quick google excluding the irrelevant gotoxy …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Can anyone tell me use of goto(x,y) in java (eclipse) ???

    To be fair, the assumption about it being a console command is just that, an assumption. There's absolutely nothing from the OP that even hints about console. Maybe it's a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Draw graph by reading values from file.

    Bonjour Mounime Don't hijack old threads, start your own. Don't just post code, explain exactly what is your question
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Active Rendering with JPanel produces Flickering

    The only way to paint is by overriding paintComponent etc You have no direct control over how often or when paintComponent will be called - it may be triggered by …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Active Rendering with JPanel produces Flickering

    You definitely should use a timer
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Active Rendering with JPanel produces Flickering

    https://www.daniweb.com/programming/software-development/threads/424529/need-help-regarding-how-to-draw-smoothly-in-java-p Except use Java.util.timer not Javax.swing.timer so model updates are not on the swing thread
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Active Rendering with JPanel produces Flickering

    Doing a getGraphics and drawing to that will never work. You have to cooperate with Swing's double buffering. The ONLY way to draw in Swing is to override paintComponent. I …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in java to notepad

    If your teacher told you that then (s)he obviously thinks you should be able to do it. If you get stuck on a particular point then people here will help …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Push each element value of myArray[ ][ ] into separte variables

    There's no sensible shortcut for this kind of thing, but the code you posted has an incorrect second loop and uses the same value for every field. Ignoring the parseInts …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in A java parser for parsing any java file in any package

    If you tell us what the error is then maybe we can help. Post the exact code and the complete error message.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in A java parser for parsing any java file in any package

    It's a simple constructor. If you don't know how to use it then, to be honest, you are not yet ready to start using tools like this.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Can anyone tell me use of goto(x,y) in java (eclipse) ???

    It' looks like a method. Which class did you find it in? According to the JLS goto is a reserved word, so the answer to "what use is goto(x,y)?" Is …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in A java parser for parsing any java file in any package

    Look at the constructors for ClassParser. You are using the one that takes an input stream, which you get from you current class loader. It would be a lot easier …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Anyone can suggest me from where I can found "de.vorb.leptonica" jar file..

    I googled for de.vorb.leptonica+jar+download and it was the first hit
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in About compiler warnings. Why do folk ignore or turn them off?

    There's a bit more to the Ariane story. The software was originally written for the Ariane 4 rocket, where it worked perfectly. Then they built the 5 which is bigger …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in ‘Guess the Word’ game in an object-oriented manner program.

    What help do you need? What have you done so far? The more effort you put in, the more people will help (and vice-versa)
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Personal Information

    I've a horrible feeling that that was all he was asking for (although a simple \n would have been sufficient). Yash : we don't do people's homework for them, but …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in About compiler warnings. Why do folk ignore or turn them off?

    I guess you know the story of the ArIane 5 rocket? Cost a gazillion Euros and blew up soon after launch. The guidance software had an assignment of a 64 …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in The Cyberg Project

    I worry that you may have no idea just how large a project it would be to write a new OS that could possibly be an alternative to what's out …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Reading Numbers from Image

    If you google "Java OCR " (optical character recognition) you will find a good number of libraries, some of which are open source. On the other hand, if you are …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in function (method in java) for c/c++ programmer

    Hi Lerner What you say is mostly right, it's just your terminology is not always standard Java usage. ;) Just for the record, here are a couple of notes... You …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in removing duplicates in arrylist but adding the units of the duplicates

    What help do you need exactly? Where are you stuck?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Hi I want to change my carrier from Php to Java

    You get excellent by writing lots of code. There's no other way. If your Java is good enough you could join an open source project on GitHub or source forge …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in function (method in java) for c/c++ programmer

    I don't know c++, but maybe the Jave equivalent would be to declare an interface. Interfaces contain method signatures but not their implementation (Java 8 changed that a but, but …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Calculate days in a month GUI

    What is the exact error message?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Single Producer 10 consumer(Parallel consumption) Problem

    So you could have a producer thread adding messages and starting a cleanup thread for each message. The cleanup threads could use a countdown latch.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Single Producer 10 consumer(Parallel consumption) Problem

    Ok, got that the second time round! It looks like you will have to use something like a countdown latch https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/CountDownLatch.html So you can have a thread waiting for the …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Single Producer 10 consumer(Parallel consumption) Problem

    Sorry, yes, it's designed for normal producer/consumer stuff. You don't often see the need to consume the same event in ten consumers.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Single Producer 10 consumer(Parallel consumption) Problem

    The easiest way is to use a blocking queue that supports multiple producers and consumers, and handles its own thread safety. See the apPI doc https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingQueue.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Using md5 or SHA1 to hash passwords in Java

    In Java hash algorithms are subclasses of `MessageDigest`. If you google Java MessageDigest you'll find lots of docs and examples.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in The Cyberg Project

    An operating system like Linux, Windows, OSX, iOS etc? That's a massive project. What are your goals? How will you know when you have succeeded?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in HELP game of life array

    Using an iteration: Life is very compute intensive when running interesting-sized simulations, so the alterMatrix logic can be time-critical. When I did this some years ago (!) I tried it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Whatever your teacher says, even if it's wrong, is what you have to do, as long as your teacher is grading your work! (yes, it sucks, but that's life) The …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in HELP game of life array

    <edit> - removed incorrect comment </edit> In `alterMatrix` you create and populate `myNewMatrix` but you never do anything with it.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in DNA CHAIN

    OK! I never really doubted that Java's `indexOf` method works correctly, so it had to be something else. Your latest code looks good to me. Don't forget to mark this …

The End.