Click here to Skip to main content
15,921,660 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two input column below, in user table external column holds True/False only.
So based on that True and False value we need to swap first name and last name.
Ex- If True then name will not swap else swap.


Source Table:

              Name             external
Vinod, Pratap (Corporate) |    False
   Anil Kumar ( |     True
          Sukant, Mohanty |     True

When the external column is "True" then output will be below in target table and where is "False" in external column then the name will be swap.
Also the code will skip (Corporate),( as well.

Target Table(Output):
FirstName   Last Name
     Anil |Kumar 
   Sukant |Mohanty
   Pratap |Vinod

What I have tried:

String str =(row4.external.toString()==True)?True:row4.external.toString();
if(str = True {
String[] strArray = str.split(",");
Updated 11-May-20 23:42pm

1 solution

You cannot compare a string to a boolean value or assign a boolean to a string:
String str =(row4.external.toString() == "True") ? "True" : row4.external.toString();
if(str == "True" {
    String[] strArray = str.split(",");

although a less complex way would be:
String[] strArray;
if (row4.external.toString() == "True")
    strArray = str.split(",");
else {
    strArray = new String[1];
    strArray[0] = row4.external.toString();
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900