Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Looping Array and Satisfying multiple conditions-Support

Threaded View

  1. #1
    Junior Member
    Join Date
    Jan 2022
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Looping Array and Satisfying multiple conditions-Support

    If I pass the url=http/market/state/update,I need the output as MARKET_STATE_UPDATE but now I am getting MARKET _UPDATE.
    please share your thoughts to help me to solve the issue


    String[] tokens = requestUrl.getPath().split("/", -1);
    for (String tokens1 : tokens) {
    switch (tokens1)
    case “market”:
    if (requestType.equals("put")) { //satisfying this condition
    if (tokens.equals("state")) { // when it comes to this line its not reading the state value
    return RecordDto.EventTypeEnum.MARKET_STATE_UPDATE;
    } else if (tokens.equals("chain”)) {
    return RecordDto.EventTypeEnum.MARKET_CHAIN_UPDATE;
    } else {
    return RecordDto.EventTypeEnum.MARKET_UPDATE; // In the end i am getting this result
    }
    } else if (requestType.equals("delete")) {
    if (tokens.equals("chain”)) {
    return RecordDto.EventTypeEnum.MARKET_CHAIN_DELETE;
    }
    break;
    Case “value”:
    if (requestType.equals("put")) {
    if (tokens.equals(“level”)) {
    return RecordDto.EventTypeEnum.Value_LEVEL_UPDATE;
    } else if (tokens.equals(“period”)) {
    return RecordDto.EventTypeEnum.Value_PERIOD_UPDATE;
    } else {
    return RecordDto.EventTypeEnum.VALUE_UPDATE;
    }
    } else if (requestType.equals("delete")) {
    if (tokens.equals(“period”)) {
    return RecordDto.EventTypeEnum.VALUE_PERIOD_DELETE;
    }
    }
    break;
    Last edited by jashvin; January 26th, 2022 at 03:57 AM.

Similar Threads

  1. LSP: weaken pre-condition and strengthen post-condition
    By Capital in forum Object Oriented Programming
    Replies: 1
    Last Post: July 13th, 2014, 12:46 PM
  2. For Loop with condition
    By mindful314 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: May 11th, 2014, 04:00 PM
  3. Array and Loop?
    By Kristenw17 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 13th, 2012, 02:23 PM
  4. Array and Loop?
    By Kristenw17 in forum Loops & Control Statements
    Replies: 1
    Last Post: November 13th, 2012, 04:58 AM
  5. For loop in array
    By Mickeydus in forum Loops & Control Statements
    Replies: 2
    Last Post: March 26th, 2012, 02:37 PM