Solved

verfiy if else statement

Posted on 2006-07-06
3
243 Views
Last Modified: 2010-04-01
folks

I have the following:

if (mroApp.equals("WOTRACK"))
            {
                  
                  mroRepName = "woprint";
            }
but i want to add a statement into this:

if (mroApp.equals("WOTRACK"))
            and (mroSite.equals("JFK"))

   mroRepName = "woprint2";

so its an if esle

could anyone advise what the correct way

the pschuedo code is

if app =wotrack then repname=woprint else if app =wotrack and site=jfk then woprint2

all other will not have the site parameter bound

all help will do

rutger

0
Comment
Question by:rutgermons
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:evnafets
ID: 17055800
The logic you specified is bad, because the second condition is a subset of the first.
If the second condition is true, the first condition is also true, and so fires first - you would never get into the second test.
Reversing the tests, putting the more specific one first would work.

I would probably write it like this.

  if ("WOTRACK".equals(mroApp)){
    mroRepName = "JFK".equals(mroSite) ? "woprint2" : "woprint";
  }

Using "WOTRACK".equals(mroApp) rather than mroApp.equals("WOTRACK") makes the code more robust by avoiding a null pointer exception if mroApp is null.
I also used a ternary statement to set the value of the mroRepName variable.

0
 
LVL 23

Expert Comment

by:Siva Prasanna Kumar
ID: 17055965
if (mroApp.equals("WOTRACK")
         && (mroSite.equals("JFK"))
   mroRepName = "woprint2";

I think this is what u wanted.
0
 
LVL 8

Accepted Solution

by:
kaliyugkaarjun earned 500 total points
ID: 17056345
If (mroApp.equals("WOTRACK"))
{
   if(mroSite.equals("JFK"))
       mroRepName = "woprint";
   else
        mroRepName = "woprint2";
}
   
   
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why do some people recommend buying business VoIP from an ISP? What are the benefits to my company? What are the costs?
This article is in regards to the Cisco QSFP-4SFP10G-CU1M cables, which are designed to uplink/downlink 40GB ports to 10GB SFP ports. I recently experienced this and found very little configuration documentation on how these are supposed to be confi…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question