Results 1 to 2 of 2
  1. #1
    pavan528 is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default Converting Range Statements to Sets in Java

    I am trying to Extract the ranges of Variables from a Text File. I extracted lines of the forms X in 1..10 Y in 12..50 Z in 0..19 / 66/ 95..100 Where X in 1 ..10 states that X takes values from set 1 to 10 Similarly for Y and for Z its a Union of different ranges of the values (0 to 19, union 66,union 95 to 100)

    I want to Map these Variables to their respective sets using Hashmap where Key is Variable name and value will be a Set. My Hashmap Signature is HashMap> hm=new HashMap>();

    Java Code:
                        String []s=line.split(" ");
                        String range=s[2];
                         System.out.println("Range =" + range);
                        //hm.put(s[0], S);
    I am stuck at extracting the variables ranges from these plain strings. Can anyone help me here with their expertise?

    Last edited by pavan528; 03-20-2014 at 03:02 AM.

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: Converting Range Statements to Sets in Java

    Please post the code you are having problems with and the contents of the file that the code is reading.
    Be sure to wrap the code in code tags:

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

Similar Threads

  1. Java runtime error: String index out of range.
    By whatson in forum New To Java
    Replies: 4
    Last Post: 08-22-2012, 09:32 AM
  2. Replies: 2
    Last Post: 05-07-2012, 06:31 PM
  3. Replies: 2
    Last Post: 01-07-2011, 12:50 PM
  4. Replies: 0
    Last Post: 07-12-2010, 11:57 AM
  5. Java Collection Framework (Sets)
    By Java Tutorial in forum Java Tutorial
    Replies: 0
    Last Post: 12-07-2007, 08:50 PM

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