• Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    readAllLines should create a List with one entry for each line in the input file. It recognises all the normal ways of separating lines for all normal operating systems.You can …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in helloWorld new javaFX projects in eclipse: start() and main()

    You update that Main class start method to create the GUI you want (or to call another method that does that).
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in helloWorld new javaFX projects in eclipse: start() and main()

    Short answer: javafx.application.Application contains all the code for initialising a JavaFX app. the normal main method just calls Application's `launch` method to get JavaFX initialised. Once FX is ready it …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    readAllLines does indeed magically find the file, open it, read all its lines into a List, and closes the file again. You just have to create the right Path object …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Yes, that's a well-known case of the compiler being stupid. Lines 16 it just sees a call to a method in the System class, but it doesn't realise that that …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    imports: In general the best thing is to only import the classes you need. That avoids problems where, unknown to you, there are classes in different packages with the same …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    > I'm importing the nio class import java.nio.file.Paths; and that seems to be enough to cover both Path and Paths, although Paths appears to be an interface, is that a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Parse String to Double and Round to 3 places

    OK, that's great. FYI, you can simplify it a bit like this: String mDisplayNominalEff = String.format(" %.3f mm", d); J
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Parse String to Double and Round to 3 places

    Simple example of formatting a float into a String: `String s = String.format("Pi = %7.4f", Math.PI);` formats the value of PI as 7 digits wide, 4 dec places (the % …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Parse String to Double and Round to 3 places

    The right time to round is when you are converting the floating point value to String - line 1 in the code you posted.Rather than using concatenation to force a …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    > required: ArrayList<String> found: ArrayList<Object> You delare your method as returning a list of <Object>, but the receiving variable is a list of <String>. You can't assign Objects to Strings. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    I think NIO is a mixed bag. It was created because of problems and limitations in the original file handling (eg support of symbolic links, OS-dependent attributes etc), but it's …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    There's nothing wrong with `Scanner inputScanner = new Scanner(new File(workingDir, fileName)); ` Yes you're creating a new File object in Java's heap, but that just refers to the same existing …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    The search will bo so fast that you can do it for every character the user types. Of course after only 1 char you will get very many hits, so …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java query

    Yeah. The "L" in the toString seems to imply some kind of list, but Lists in general use Collection's toString that gives a concatenation of all the lement's individual toStrings …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java query

    Looking further at your code fragment, can I guess that you are using JavaFX? If that's the case then the addAll method is for an ObservableList that you got from …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java query

    "[Ljava.lang.Object;@64bba873" Is the result of your list view calling `toString() `on your data to convert it to a String for display. That output is the default `toString()` that every class …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    Ooops, yes you're right. So no need to change or re-write anything there.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    1. If you have code that does what you want then re-use it. That's just "working smart". But in this case I think your existing code writes 1 word per …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Gave Reputation to moin ali khan in bank management system in assembly language

    i have a project in assembly language. i just cannot make this out. i have to submit that in few days. any programmer or assembler who has already made that …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    A binary search can be implemented for any data type or class that can be sorted into a known order, so Strings are definitely possible. The problem here is that …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Recursion in a for and while loop

    > I always loose the stack sequence.. I don't really know how to improve this There's no magic answer. Just step through the code one line at a time and …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Recursion in a for and while loop

    You just need to get a pencil and paper and work through the order of execution. Something like... doAnagram(4) calls doAnagram(3) (line 27) before it can call rotate (line 32) …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Searching algorithm to search through strings

    If the term you are searching for can be anywhere in the sentence, then sorting isn't going to relevant, and binary search won't help. If you will always be searchng …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Can anyone tell me how to read UTF-16 encoded file in java 7 ??

    You need an `InputStreamReader` to read and decode text using UTF-16 encoding. You specify the charset when creating the InputStreamReader, eg `InputStreamReader in = new InputStreamReader(myInputStream, StandardCharsets.UTF_16);` Anything you read …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in why wont this program work

    I just gave pseudo code to explain the structure, not full Java - that's up to you. Line 1 above is NOT a valid declaration of a method, but you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in why wont this program work

    It won't work because it's too hard to debug. Nobody is going to debug a loop and nested ifs that stretch over 200 lines - it's just too hard. Refactor …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in How to replace a string with table using java?

    That makes no sense. In Java a string is an internal data item that holds a single sequence of chars A table is either a 2 dimensional GUI component or …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    It just avoids the problem of you having to get the right OS-dependent separator.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    Right idea, wrong syntax for a method call. It goes like this: String myDir = ..... (maybe from system properties) String fileName = ..... File f = new File(myDir, fileName); …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java OOP class method objects

    Sorry, I don't understand what help you need - you have created your classes, you have created various methods, including overridden methods, so now all you need is a bit …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Moving Strings from one class into another in JAVA

    Hi AgentOxegen I think you're in trouble here - trying to write some custom graphics before you know to to create a simple class. There's to much missing inbetween for …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Moving Strings from one class into another in JAVA

    Your FinalProjectQuestions class is written as if it's a first Java project, not a final. For a final project then you are probably expected to define a class that holds …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I need a help with this Class I made.

    That looks like the LibraryRecord class is not visible from the MainErgasia class. That's possibly something to do with the directory structure where they are held. Unless you are using …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I need a help with this Class I made.

    Your constructors are defined as having some String and some int parameters., but when you call the constructors you just pass a lot of Strings. Ie: the compiler is looking …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in I need a help with this Class I made.

    No You use names like BookTitle, but you never declare any variables with those names. Everything in Java must be declared. In your constructor you should initialise the variables you …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in data insertion error into mysql database

    This is al ablout timing - when things happen. JTextField enterdata = new JTextField(10); s1=enterdata.getText(); This creates a text field and immediately queries it for the text it contains. At …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Can software cracker reveal original variable content?

    If the program uses the value (and if it doesn't then why have it?) then the program must contain some encoded version of the value and some code to decode …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java OOP class method objects

    What have you tried so far? Have you created the subclasses like the tutorial I linked?
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java OOP class method objects

    OK, some small errors there but it's on the right tracks. What help do you need? If you are having problems declaring subclasses this tutorial may help: http://docs.oracle.com/javase/tutorial/java/javaOO/classes.html
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in converting Hex string to Byte causing numberFormatException pls help my why

    The string vaue must be in the range for a byte, ie -128 to +127 (ie -80 to 7f hex). Your value of ac is too large for a byte. …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in HTML: Symbol (Circle) as Tracker in Google Map

    Looks like javascript, not java. I've added a javascript tag.
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    Don't have linux here so I can't say. But why not use the File constructor that goes *public File(String parent, String child) Creates a new File instance from a parent …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in iterate over hashmap entryset

    OK, yes you can iterate through the `entrySet()` (hint!). For each entry you can `getKey()` and `getValue() `and test them to see if either is the one you want
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    > I didn't know that calls from outside methods were not allowed You know that you can't put any kind of executeable code just lying around in a class. It …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    You tried to call it from inside the inner class *but outside any method*! Because its outside any method the compiler is confused and thinks you are trying to define …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Application to save word/sentences to file

    An inner class has access to all the variables and methods in its containing class (that's why you make them inner classes!) so there's no problem calling the outer class's …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in any example to call the .java file using php

    .java is a source code file so you can't execute it. Yo have to compile it first Compiled java programs that can be executed come in .class files or .jar …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Get the xml parent node and child nodes

    Please don't be upset by jwenting - he's notoriously grumpy. There are many tutorials on how to parse XML in Java - just Google for them. As always, Oracle's own …
  • Member Avatar for JamesCherrill
    JamesCherrill

    Replied To a Post in Java hashmap loop through key values

    I tried reading that a few times, but it still makes no sense, and the code you were given (a) also makes no sense and (b) isn't valid code and …

The End.