Checking value and displaying blank instead of null

Hi,
I was wondering how do I check in the code if the value is null then display a blank as suppose to displaying the word null??
what I have now is:
column1 column2
24 null
want
24
I've tried:
if ("".equals(string))
out.println(" ");
if (string.equals(""))
if (string.equals(null))
thanks,
Will

Use s == null to test if the String s is null, then if yes, replace it with the blank string "". See the code bellow:
class MyString {
    String[][] sa={{"column1", "column2"},
             {"24", null},
             {"want", "24"},
    public String toString() {
     String result = "";
     for (int i=0; i < sa.length; i++) {
         for (int j=0; j < sa.length; j++) {
          if (sa[i][j] != null) {
          result += sa[i][j];
          else {
          result += "";
          result += "\t";
     result += "\n";
     return result;
public static void main(String[] args) {
     MyString ms = new MyString();
     System.out.println(ms.toString());

Similar Messages

  • List Box showing Value and Display members?

    Ok this is a CONCEPT problem (the code is not professional, just read it for the concept, though it does compile and run).
    Right, I have asked many people on IRC and no one is giving me a straight answer lol so maybe some professionals can help me.
    I am trying to use a Datasource property for my combobox. This is so I can just pass an entire KeyValue pair with indexes and values to be shown in the listbox.
    Creating the keyvaluepair as a WHOLE and passing that to datasource property works perfectly.
    Creating a keyvaluepair PROCEDURALLY (in a loop or w/e) ends in the datasource property ToString()ing it, list box items show BOTH value AND display members in square brackets as an entire option.
    NOTE: Getting the lsitbox.value results in ONLY the valuemember being returned even though the listbox shows both the valuemembers AND the displaymember? it knows they are different?
    Now, I dont want any alternatives or comments about the quality of the code, all I want to know is WHY is it doing this, it seems compeltely illogical that the same TYPE and Values and can different Effects within the datasource property? Its like it knows
    it was built procedurally?
    Anyway here is some code for reference:
    // Windows Form
    namespace skbtInstaller
    public partial class frmMainWindow : Form
    public frmMainWindow()
    InitializeComponent();
    // coxArmaPath = Combo Box (simple drop down)
    this.cBoxArmaPath.ValueMember = "Key";
    this.cBoxArmaPath.DisplayMember = "Value";
    public void addServerPathItem(String Key, String Value)
    this.cBoxArmaPath.Items.Add(new KeyValuePair<String, String>(Key,Value));
    // This works fine, only the "DisplayMember" is displayed and the "ValueMember" is hidden.
    // This acts differently with the same types???
    public void setServerPathDatasource(List<KeyValuePair<String, String>> source)
    this.cBoxArmaPath.DataSource = new BindingSource(source, null);
    public class skbtServerControl
    private frmMainWindow frmMainWindowHandle;
    public void refreshformWindow()
    // Clear Drop Box (empties drop box)
    this.frmMainWindowHandle.clearPathBox();
    //skbtServerConfig is very simple property object
    foreach (KeyValuePair<String, skbtServerConfig> pair in CoreConfig.getServerConfigList())
    // Populate Drop Box
    this.frmMainWindowHandle.addServerPathItem(pair.Key, pair.Value.getTextualName()); // this works as intended
    // cBox gets items like: Some Display Text, Some Display Text, Some Display Text (PERFECT!)
    // This works absolutely fine. ValueMembers are hidden.
    public void refreshformWindowWithSTATICDatasource()
    // Clear Drop Box
    this.frmMainWindowHandle.clearPathBox();
    var pathDataSource = new List<KeyValuePair<String, String>>()
    new KeyValuePair<String, String>("testKey1", "somevalue1"),
    new KeyValuePair<String, String>("testKey2", "somevalue2"),
    new KeyValuePair<String, String>("testKey3", "somevalue3")
    // Populate Drop Box
    this.frmMainWindowHandle.setServerPathDatasource(pathDataSource);
    // cBox gets items like: Some Display Text, Some Display Text, Some Display Text (PERFECT!)
    // ** HERE IS THE PROBLEM?? **
    // This creates a type that seems different to the above function which works fine...
    public void refreshformWindowWithDatasource()
    // Clear Drop Box
    this.frmMainWindowHandle.clearPathBox();
    var pathDataSource = new List<KeyValuePair<String, String>>();
    //skbtServerConfig is very simple property object
    foreach (KeyValuePair<String, skbtServerConfig> pair in CoreConfig.getServerConfigList())
    pathDataSource.Add(new KeyValuePair<String, String>(pair.Key, pair.Value.getTextualName()));
    // Populate Drop Box
    this.frmMainWindowHandle.setServerPathDatasource(pathDataSource);
    // cBox gets items like [asjAETJQ5785d45,Some Display Text], [asawfgQ5785d45,Some Display Text], [asjAhrrQ5785d45,Some Display Text]
    // ????? surely this function should act exactly like the function above??
    Thanks!
    (I have posted on codeproject too, will condense any replies).
                 

    Thanks Michael!
    I did debug this and it turns out when i set a new BindingSource to the combo box, indeed the DisplayMember gets reset. Oddly though, the ValueMember stays the same.
    I have fixed this with setting the Members before every new bindingSource is set to the combobox, strange that only the displaymember is reset?
    For reference, the new resolved code: (this compiles albeit with designer components placed)
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    namespace etstapp1
    public partial class Form1 : Form
    private skbtServerControl sc;
    public Form1()
    InitializeComponent();
    this.sc = new skbtServerControl(this);
    // coxArmaPath = Combo Box (simple drop down)
    this.cBoxArmaPath.ValueMember = "Key";
    this.cBoxArmaPath.DisplayMember = "Value"; // This doesnt seem to stick after the first datasource set??
    public void addServerPathItem(String Key, String Value)
    this.cBoxArmaPath.Items.Add(new KeyValuePair<String, String>(Key, Value));
    // This works fine, only the "DisplayMember" is displayed and the "ValueMember" is hidden.
    // This acts differently with the same types???
    public void setServerPathDatasource(List<KeyValuePair<String, String>> source)
    this.cBoxArmaPath.DisplayMember = "Value"; // fix datasource problem
    this.cBoxArmaPath.ValueMember = "Key"; // fix datasource problem
    this.cBoxArmaPath.DataSource = new BindingSource(source, null);
    public void clearPathBox()
    if(this.cBoxArmaPath.DataSource == null){
    this.cBoxArmaPath.Items.Clear();
    else
    this.cBoxArmaPath.DataSource = null;
    private void btnStatic_Click(object sender, EventArgs e)
    this.sc.refreshformWindowWithSTATICDatasource();
    private void btnNormal_Click(object sender, EventArgs e)
    this.sc.refreshFormWindow();
    private void btnDynamic_Click(object sender, EventArgs e)
    this.sc.refreshformWindowWithDatasource();
    public class skbtServerControl
    private CoreConfig CoreConfig;
    private Form1 frmMainWindowHandle;
    public skbtServerControl(Form1 f){
    this.frmMainWindowHandle = f;
    this.CoreConfig = new CoreConfig();
    public void refreshFormWindow()
    // Clear Drop Box (empties drop box)
    this.frmMainWindowHandle.clearPathBox();
    //skbtServerConfig is very simple property object
    foreach (KeyValuePair<String, skbtServerConfig> pair in CoreConfig.getServerConfigList())
    // Populate Drop Box
    this.frmMainWindowHandle.addServerPathItem(pair.Key, pair.Value.getTextualName()); // this works as intended
    // cBox gets items like: Some Display Text, Some Display Text, Some Display Text (PERFECT!)
    // This works absolutely fine. ValueMembers are hidden.
    public void refreshformWindowWithSTATICDatasource()
    // Clear Drop Box
    this.frmMainWindowHandle.clearPathBox();
    var pathDataSource = new List<KeyValuePair<String, String>>()
    new KeyValuePair<String, String>("testKey1", "somevalue1"),
    new KeyValuePair<String, String>("testKey2", "somevalue2"),
    new KeyValuePair<String, String>("testKey3", "somevalue3")
    // Populate Drop Box
    this.frmMainWindowHandle.setServerPathDatasource(pathDataSource);
    // cBox gets items like: Some Display Text, Some Display Text, Some Display Text (PERFECT!)
    // ** HERE IS THE PROBLEM?? **
    // This creates a type that seems different to the above function which works fine...
    public void refreshformWindowWithDatasource()
    // Clear Drop Box
    this.frmMainWindowHandle.clearPathBox();
    var pathDataSource = new List<KeyValuePair<String, String>>();
    //skbtServerConfig is very simple property object
    foreach (KeyValuePair<String, skbtServerConfig> pair in this.CoreConfig.getServerConfigList())
    pathDataSource.Add(new KeyValuePair<String, String>(pair.Key, pair.Value.getTextualName()));
    // Populate Drop Box
    this.frmMainWindowHandle.setServerPathDatasource(pathDataSource);
    // cBox gets items like [asjAETJQ5785d45,Some Display Text], [asawfgQ5785d45,Some Display Text], [asjAhrrQ5785d45,Some Display Text]
    // ????? surely this function should act exactly like the function above??
    public class CoreConfig
    public Dictionary<String, skbtServerConfig> getServerConfigList(){
    return new Dictionary<string, skbtServerConfig>()
    {"somekey1", new skbtServerConfig("somename1")},
    {"somekey2", new skbtServerConfig("somename2")}
    public class skbtServerConfig
    private String name;
    public skbtServerConfig(String name)
    this.name = name;
    public String getTextualName()
    return this.name;
    Talking with someone it seems logical that every time I set a new BindingSource the component will not know if I want to keep the same member values so it resets them, but why it only resets displaymember? very strange to me.
    Thanks again.

  • How to display Blanks instead of # in Report

    Hi All,
    In my report we are getting # for all blanks. Any one have idea how to display Blank instead of #.
    Thanks
    Vani

    You can do it using Excel macros. See the links for more info:
    [Re: replacing '#'-sign for 'not assigned' in queries]
    [How do I replace "#" to "NoData" in the workbook;

  • There are no icons of the apps i downloaded. I mean, I used them for a while, then my iPod died, I charged it a little, then turned it on, and saw blanks instead of apps. They work pretty fine, but there are no icons, just white rectangles. What can I do?

    There are no icons of the apps i downloaded. I mean, I used them for a while, then my iPod died, I charged it a little, then turned it on, and saw blanks instead of apps. They work pretty fine, but there are no icons, just white rectangles. What can I do?

    - First try resetting the iPod:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    - If still problem restore the iPOd via iTunes on your computer.  First from backup and if problem persists restore to factory defaults/new iPod.

  • Inserting blank values and retrieving blank values

    I really want to Insert blank values into Oracle database,and also want to retrieve blank values from table.
    When I try to insert blank values ,Its inserting null values.
    I don't want to insert null for blank.
    Please provide me solution for this.
    Thank you

    user631179, logically if you have a descrition or other printable
    character column where the value is blanks you do not have a value.
    The data item is logically unknown or non-existent, hence NULL.
    You can assign blanks (spaces) for NULL in the querying program
    like SQLPlus does on display. The Pro*C and other language tools
    provides null indicator bytes for this purpose.
    UT1 > l
      1  select fld1, fld2, rpad(nvl(fld4,' '),10,' '), length( rpad(nvl(fld4,' '),10,' '))
      2* from marktest
    UT1 > /
    FLD1             FLD2 RPAD(NVL(F LENGTH(RPAD(NVL(FLD4,''),10,''))
    one                 1                                          10
    TWO                 2 USER51                                   10
                        4 USER51                                   10HTH -- Mark D Powell --
    Message was edited by: Mark to try to keep the test from requiring scrolling
    mpowel01

  • Captute the check box and display

    hi,
    In a report program se38, with the output I've displayed the check boxes before every line item, I need to keep a check box in the header row and if I check this one all the check boxes of the line items must be checked and I need to capture the particular line items if checked manually and randomly.
    i did not use grid display its a simple display with write statements.
    (in short if the first(header) check box is checked need to check remaining and need to process the check box itmes if checked as above and manually)
    thanks and regards with rewards later on

    Hi,
    Check this sample code...
    DATA: t_lineitem TYPE TABLE OF char1.
    DATA: s_lineitem LIKE LINE OF t_lineitem.
    DATA: v_header,
          v_index TYPE syindex.
    START-OF-SELECTION.
      WRITE: / 'Header check box',  v_header AS CHECKBOX.
      SKIP 2.
      DO 10 TIMES.
        s_lineitem = sy-index.
        WRITE: / 'Line item-', sy-index , s_lineitem AS CHECKBOX.
        APPEND sy-index TO t_lineitem.
      ENDDO.
    AT LINE-SELECTION.
      READ LINE 1 FIELD VALUE v_header.
      DO .
        v_index = sy-index + 2.
        READ LINE v_index FIELD VALUE s_lineitem.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
        s_lineitem = v_header.
        MODIFY CURRENT LINE FIELD VALUE s_lineitem.
      ENDDO.
    Thanks
    Naren

  • Retrieve list items from the textbox text value and display the dropdownlist item for that particular list item

    hi,
     I have created a custom list in my sharepoint :
    List1 name:   employeedepartment  -
                   Title       empdepartment
                   A             D1
                   B             D2
                   C             D3 
    List2  name:  employeedetails  
     emptitle            empname       empdepartment(lookup) --> from the list "employeedepartment"
       x                     Ram                 D1
       y                     Robert             D2
       z                     Rahim              D3
    My task is to create a custom webpart that will be for searching this employee details by entering emptitle
    For this, i have created a visual webpart using visual studio 2010, my webpart will be like this:
    emptitle  --->  TextBox1                        Button1--> Text property : Search
    empname---> TextBox2
    empdepartment-->  DropDownList1
    For this, i wrote the code as follows:
    protected void Button1_Click(object sender, EventArgs e)
                using (SPSite mysite = new SPSite(SPContext.Current.Site.Url))
                    using (SPWeb myweb = mysite.OpenWeb())
                        SPList mylist = myweb.Lists["employeedetails"];
                        SPQuery query = new SPQuery();
                        query.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + TextBox1.Text.ToString() + "</Value></Eq></Where>";
                        SPListItemCollection myitems = mylist.GetItems(query);
                        if (myitems.Count > 0)
                            foreach (SPListItem item in myitems)
                                string a1 = Convert.ToString(item["empname"]);
                                string a2 = Convert.ToString(item["empdepartment"]);
                                TextBox2.Text = a1;           // displaying   properly                    
                                //DropDownList3.SelectedIndex = 1;                           
     It is showing the list item in textbox according to the item entered in the textbox1... But I am stuck to show in the dropdown list. 
    Suppose, if i enter X in textbox and click on search, then dropdownlist need to show D1,
                               for Y --> D2 and for Z-> D3... like that.
    What code do i need to write in the button_click to show this... 
    Please don't give any links...i just want code in continuation to my code.

    Hi,
    Since you have got the data you want with the help of SharePoint Object Model, then you can focus on how to populate values and set an option selected in the Drop Down List.
    With the retrieved data, you can populate them into the Drop Down List firstly, then set a specific option selected.
    Here is a link will show how to populate DropDownList control:
    http://www.dotnetfunda.com/articles/show/30/several-ways-to-populate-dropdownlist-controls
    Another link about select an item in DropDownList:
    http://techbrij.com/select-item-aspdotnet-dropdownlist-programmatically
    Best regards
    Patrick Liang
    TechNet Community Support

  • Validate the XML tag value and display the Binding data in XDP

    Hi,
    I am new to Adobe Life Cycle.... and i am working on the following requirement and XML file is enclosed...
    1. Need to validate the XML value of <pp> with condition
    2. Basing on the value of <pp>, need to display the <ct> values in text field
    If i simply bind, it takes the values from top of array and display..
    Please suggest how to restrict the binding values basing on the condition.
    Thanks
    Madhu

    Hi Paul,
    Thank you for quick respose.
    The solution which you have give me not excatly looking for.... working for the solution in alternative methods...
    Regards
    madhu

  • Check database and Display Message

    First of all sorry if this isn't the correct subforum to post this question.
    I want to make a date keeper program. so when the time of the appointment,
    has reached i want to display a message with the data of the appointment.
    i have though to make the whole gui running under a thread and to make another thread which
    constantly check the database every 1 minute. and display the appropriate message.
    is there any better and easier way.
    any help is appreciated!

    please some help here, cause with the threads i don't know why but my
    application crushes after 1 minute while it's running.
    any help is appreciated!

  • I turn on but 9 beeps and display blank

    i turn on my macbook pro but 9 beeps and display blank

    Beeps when you turn your system on means there is a memory issue. The memory might be bad or missing or the wrong memory for the system or could indicate a logic board issue. The first thing you should do is to reseat the memory. Take each memory card out and put it back, then try to boot your system. If that doesn't work, and you have an alternate set of known working memory, perhaps from a friends MBP (with the same memory), try that. If that doesn't work, then your system needs to be taken to your local Apple store or Apple Authorized Service Provider.

  • How to get selected item value and display text in selectOneChoice ?

    Hi
    Thank you for reading my post
    I bind the a selectOneChoice component to my backing bean so i have an object which represent this component in the backing bean.
    now i need to find which item is selected by use , i know that i can use
    getSelect_service().getValue.toString() , but it will return the value of the selected item, how about its display text ?
    I should say that i create an static list for selectOneChoice items.
    thanks

    Using JDeveloper 10.1.3.1, freshly downloaded off OTN. I used the following code to try and identify the problem you are encountering. I attempted to use a valueChangeListener in combination with af:selectOneChoice components that use SelectItems and the singular SelectItem. I could not reproduce the error in either case. Please post more information about your development environment.
              <af:selectOneChoice label="Label 1"
                                  binding="#{backing_test.selectOneChoice1}"
                                  id="selectOneChoice1"
                                  valueChangeListener="#{backing_test.valueChangeListener}"
                                  autoSubmit="true" immediate="true">
                <af:selectItem label="1" value="1"
                               binding="#{backing_test.selectItem1}"
                               id="selectItem1"/>
                <af:selectItem label="2" value="2"
                               binding="#{backing_test.selectItem2}"
                               id="selectItem2"/>
                <af:selectItem label="3" value="3"
                               binding="#{backing_test.selectItem3}"
                               id="selectItem3"/>
              </af:selectOneChoice>
              <af:selectOneChoice label="Label 2"
                                  binding="#{backing_test.selectOneChoice2}"
                                  id="selectOneChoice2"                              valueChangeListener="#{backing_test.valueChangeListener}"
                                  autoSubmit="true" immediate="true">
                <f:selectItems value="#{backing_test.items}"
                               binding="#{backing_test.selectItems1}"
                               id="selectItems1"/>
              </af:selectOneChoice>
        public void valueChangeListener(ValueChangeEvent evt){
            // returns a UISelectOneChoice object
            System.out.println(evt.getSource().getClass().getName());
            // returns a string
            System.out.println(evt.getNewValue().getClass().getName());
        public Map getItems(){
            items = new HashMap();
            items.put("11","11");
            items.put("12","12");
            items.put("13","13");
            return items;
        }

  • Dropdownlist box value and display field retrieval question

    have a case on a dropdown list where I want to not only retieve the value from the selected item, but I also want to retrieve the display field. I know that you use the the tempDropdownlist.getValue() to get the value, but how do you retrieve the display field?
    The dropdown box is bound to a table with id(int) and Name(string).

    Yes there's no easy way - but you can loop thru the select items list and find the one that matches the current getValue result... and get it that way - see the tutorial on Using Listbox Components...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    hth,
    v

  • Query Stripping: how to filter a value and display the detail

    Hi,
    We have just upgraded to XI 3.1 SP3.1, and I have done some tests on the query Stripping functionnality. I can see the benefits from a performance point of view if I dragged new characteristics to the report, but I was not able to reproduce one of our key requirements:
    The report displays Sales by Manager, the customer is in the webi query panel but not in the report. So far, thanks to the query stripping option, webi only retrieves the Manager information and not the customer.
    Now, the user wants to see the sales by customer for a particular manager. If I drag and drop the customer, I have the customers for all the managers, and I now have a performance issue.
    I just would like to do as in BEX: Filter and Drill Down.
    I know that I can use the Drill Functionnality of webi, but it is a fixed scenario that you have to define in advance in the universe. It has also the inconvenient to drill only to the key or the description of an object (cannot drill down to the key and description of the customer).
    Any tip to do a "filter and Drill Down" using the query stripping functionnality?
    THank you,
    Gabriel

    Hi,
    Drag from output port of dataservice and select "filter data" option. Then if you select "configure element" for filter operator, you can see the fileds.
    The filter conditions for a numeric field is as follows
    Equals 100 - <b>100</b>
    Not equals 100  - <b>not 100</b>
    greater than 100 - <b>100..</b>
    <= 100 - <b>not 100..</b>
    <100 - <b>..100</b>
    I think you got the logic here. the two dots at the end shows greater while dots at the begining shows less than. If the dots are in the middle of two numbers, the filter operator  will return values between the two numbers
    Regards,
    Sooraj

  • Error with doing sum of distinct value and displaying of data in SSRS

    from the picture each food is 1 month. when the report if i put sum(output) so month 1 = 10 month 2 =20 month 3 =30. when i collapse the thing i want to see 10+20+30. but however it shows (10*6)+(20*6)+(30*6)=360.but
    the correct value should be 60.. i tried the row id.. it is able to give me the value of 60 when i collapse the things but when i expand the thing only the first row is shown, i.e only spinach is shown.
    furthermore I cannot use aggregate within a n aggregate  :  sum(first(output))..
    Is there anyway to achieve sum(first(output))  in another way ?
    Anyone know how to show this?

    You need to add group total in the tablix and bring the running count in the group cell. Say for Month 1 the max running count is 6. Bring that 6 to the group row. Try using
    PREVIOUS function/Custom Code.
    Refer this link
    http://technet.microsoft.com/en-us/library/ms170712.aspx
    Regards, RSingh

  • Read a property file value and display in jsp page

    I need a solution for the below mentioned scenario,
    I want to read a value from the property file in JSP page.
    For Example, Let us have a property file called A.properties, in the file, we have a value, username = Sam.
    I want to bring this value in the jsp page.
    Please assist in this issue.
    thanks in advance.

    If you are using struts, then you have to first load the taglib like
    <%@ taglib uri="/WEB-INF/strutsresources/struts-bean.tld" prefix="bean" %>and then access the particular property like
    <bean:message key="welcome"/>Also, you have to define <message-resources> in struts-config. Though I am not into struts for year now, So, please confirm the code.

Maybe you are looking for

  • Text output from 11i Reports to Excel - bad Format

    Hi All, We have a report in Oracle Apps 11i(11.5.10) with Text as output format. We would like to open the file in Excel format. We have done the recommended setups from the metalink note ID 316752.1. Output is generated in Excel, but the format is n

  • Problems with MTP firmw

    The 2.00.2 MTP firmware always crashes when trying to update my Zen Micro. I have installed the software updates and .02.05 firmware without a problem. The other firmware gets to about halfway through until it says "rebooting device" for the second t

  • Help newbie: in running sample CORBA and EJB

    HI, I am trying to run the samples that come along with the http server for 8.1.7, all the examples work except for these two, for the CORBA,I am able to load and publish, and works perferctly from the client (used runit.bat) but when i try to run fr

  • Call R3 report by Process Chain BW

    Hi, I need to execute an R3 abap program from a Process Chain in BW, and after it finish, process chain has to continue its processes... Could someone help me? thank you Fede

  • Planed costs on Simulation Version

    Where can I see the planed costs on Simulation? I have an escenario where the project is created as Simulation, and after this one is evaluated on duration and costs, the user transfer the simulation to an operative project, but I need to see the pla