Note that there are some explanatory texts on larger screens.

plurals
  1. POPrinting string array also prints null
    primarykey
    data
    text
    <p>When I am printing contents of a string array the output is printing 'null' as well. I am not sure what's wrong with this. Here is the output, what I expect is the output without 'null'</p> <pre><code>null(wa?&gt;=0)nullnull*(wo?&gt;=0)nullnull*(4*wa?+7*wo?&gt;=50)nullnull*(d1=10)nullnull*((d2=1)+(k=2))nullnull </code></pre> <p>Thanks and appreciate your help. I would say my skill in Java in beginner level and I started two weeks back.</p> <p>Here is the actual code:</p> <pre><code> String[] arrStr = new String[50]; int countStr = 0; for (int i = 0; i &lt; para.length; i++) { if (para[i] == '(') { count = count + 1; } if (para[i] == ')') { count = count - 1; } if (count &gt; 0) { arrStr[countStr] = arrStr[countStr] + para[i]; } else { if (para[i] == ')') { arrStr[countStr] = arrStr[countStr] + para[i]; countStr += 1; } else { countStr += 1; arrStr[countStr] = arrStr[countStr] + para[i]; // System.out.println(para[i]); } } } System.out.println(countStr); for (int i = 0; i &lt; countStr; i++) { System.out.print(arrStr[i]); } </code></pre> <p>Before this part, I am reading the following string from a word document:</p> <pre><code>(wa?&gt;=0)AND(wo?&gt;=0)AND(4*wa?+7*wo?&gt;=50)AND(d1=10)AND((d2=1)+(k=2)) </code></pre> <p>I think the problem may be due to the line: </p> <pre><code>arrStr[countStr] = arrStr[countStr] + para[i]; </code></pre> <p>Since <code>arrStr[countStr]</code> is null initially and I add an element to it, it saves it as <code>null+para[i]</code>. Do you think it is possible? </p> <p>Like when I try: <code>System.out.println(arrStr[0]);</code> I get the output as </p> <pre><code>null(wa?&gt;=0) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload