This is the mail archive of the java-prs@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

java/10253: String concatenation with int zero, as in ""+0, results in the empty string.


>Number:         10253
>Category:       java
>Synopsis:       String concatenation with int zero, as in ""+0, results in the empty string.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Fri Mar 28 09:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Lars Andersen
>Release:        gcc version 3.3 20030324 (prerelease)
>Organization:
>Environment:
Redhat Linux 8.0.96 x86, Athlon XP 
>Description:

Concatenation of String and int 0 is wrong.

Consider this program :

> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

public class Test
{

? public static void main(String[] args)
? {
??? System.out.println("Test");
??? System.out.println(""+0);
??? System.out.println(""+1);
? }
}

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

I would expect the output to be :

Test
0
1

, but this is what i get :

Test

1
>How-To-Repeat:
Compile Test.java
> gcj --main=Test Test.java -o test
Run test
> ./test

It outputs :
Test

1
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]