String concatenation not happening with midp classes
$ javac -bootclasspath /opt/midp/classes MyMIDlet.java
When I compile my code with the above command, I get the following error:-
MainCanvas.java:192: cannot access java.lang.StringBuilder
class file for java.lang.StringBuilder not found
String name = firstname + " " + surname;
-^
It can't append the strings using the + operator. But when I compile and run the same code using NetBeans IDE or Sun WTK 2.5.1, it runs fine.
[467 byte] By [
Nortona] at [2007-11-27 6:25:53]

# 3
> well dont use concatanation operator. Rather use
> StringBuffer class that really optimize your memory
> on device.
you can use concatenation operator ...
it comes from the compilation. i think that it was compilated in 1.5 (1.5 generates StringBuilder
for concatenate Strings) !
# 4
> you can use concatenation operator ...
> it comes from the compilation. i think that it was
> compilated in 1.5 (1.5 generates StringBuilder
> for concatenate Strings) !
Yes. very much true... it must be 1.5 or higher (1.6).
Excerpt from Javadoc : The Java language provides special support for the string concatenation operator ( + ),
and for conversion of other objects to strings.
String concatenation is implemented through the StringBuilder(or StringBuffer) class
and its append method.
If you use 1.4 then this will not happen.
And if this is true then you should give the dukes to supareno. As he is the one who got it first.
Regds,
SD
# 6
Well J2ME api set primarily is a primitive subset of Java 2 with some extra api added. It is becoming so reacher day by day that the Sun guys are implementing some ME api to work with SE/EE, and there are offcours many more to come.
And if u want that u should be given the StringBuilder in ME so that u can concat Strings in ME like SE way, you should ask the Sun guys for it. U see u are asking the wrong people here for it.
# 7
> Ok so JDK 1.4 used StringBuffer for concatenation
> where as JDK 1.5 and 1.6 use StringBuilder. If that
> is the case, shouldn't Sun provide the StringBuilder
> class in the MIDP 2.0 specification?
maybe too many huge changes...
now sun opens java sources so you can try to do your own virtual machine for mobile if you
want.
you just need to compile your sources with 1.4 source version...
don't forget the dukes :)