Results 1 to 4 of 4
  1. #1
    CodePuppy is offline Member
    Join Date
    Mar 2017
    Posts
    1
    Rep Power
    0

    Default What is a effective and easy way to parse int, boolean to int

    What is a effective and easy way to parse int, boolean to int



    import java.io.*;
    import java.lang.*;
    import java.util.*;

    public class createFile {
    public static void main(String[] args) {
    }


    private Formatter x;
    private String input;

    public void openFile() {


    {
    try {
    x = new Formatter ("inputFile.txt");
    } catch (FileNotFoundException e1 ) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    System.out.println("error ");
    }
    }
    }
    //

    // For testing above method:

    /*public static void main(String[] args) throws Exception
    {
    String doubleString = "3.56";
    java.util.Map.Entry<Boolean, Double> result = tryParseDouble(doubleString);

    System.out.println("Valid: " + result.getKey());
    System.out.println("Double Value: " + result.getValue());

    doubleString = "string";
    result = tryParseDouble(doubleString);

    System.out.println("Valid: " + result.getKey());
    System.out.println("Double Value: " + result.getValue());
    }*/



    //
    int a = 2; //global variable, lives until program termination

    int& foo() {
    return a;
    }

    public void addRecords() {
    } {
    x.format ("s%s%s", "happy", "Rick", "");
    }
    public void closeFile() {
    } {
    x.close();
    }


    }

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,942
    Rep Power
    30

    Default Re: What is a effective and easy way to parse int, boolean to int

    way to parse int, boolean to int
    See the methods in the Integer class for parsing Strings to int values.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    gozzy is offline Member
    Join Date
    Jan 2017
    Posts
    46
    Rep Power
    0

    Default Re: What is a effective and easy way to parse int, boolean to int

    Java Code:
    java.util.Map.Entry<Boolean, Double> result
    How would that work? That Map could have two entries at the most - is that what you want?

  4. #4
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,170
    Rep Power
    12

    Default Re: What is a effective and easy way to parse int, boolean to int

    The OP needs to do three things.

    1. Clean up the code
    2. Use code tags.
    3. Explain what is required

    Note that above code has errors. The following statements are not inside a class.

    Java Code:
    private Formatter x;
    private String input;
    And

    Java Code:
    int& foo() {
            return a;
    }
    is incorrectly declared and not used anywhere.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. Replies: 6
    Last Post: 01-16-2014, 01:48 PM
  2. Replies: 5
    Last Post: 07-12-2013, 01:22 AM
  3. Replies: 3
    Last Post: 05-11-2013, 06:27 AM
  4. Replies: 3
    Last Post: 09-13-2011, 12:01 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •