On Wed, 5 Jul 2000, Tony J. Paul wrote:
> Hi brEezE,
>
> I am new to this list. I don't know if this will suffice your
> requirement. Anyway, Why don't you try StringBuffer class? You can use
> it like this,
>
> StringBuffer sb=new StringBuffer();
> sb.append("SELECT COF_NAME, ");
> sb.append("SALES FROM COFFEES ");
> stmt.executeQuery(sb.toString());
>
I recall reading somewhere that the following code is optimized by javac
(roughly) into the form you provided just above:
String s;
s = "SELECT COF_NAME, ";
s += "SALES FROM COFFEES ");
s += "WHERE COF_NAME = 'Starbucks'";
stmt.executeQuery(s);
In other words, the compiler optimizes successive calls to the += operator
into StringBuffer.append() calls without creating a bunch of intermediate
objects. Does javac actually do this, or do I need to go back to the ugly
StringBuffer idiom for efficiency?
> Moreover, the "+" sign is actually over loaded in JAVA. Internally,
> for every "+" a string buffer is instantiated and does what I have shown
> above. So using string buffer would be more efficient.
>
> regards
>
> Tony P.
>
>
>
> brEezE wrote:
>
> > Hi all, I have a dummy question regaring a
> > double-quoted string written in multiple line.
> > Here is what I have been doing:
> > stmt.executeQuery( "SELECT COF_NAME, " +
> > "SALES FROM COFFEES " );
> >
> > Is there a way to to eliminate the '+' sign by doing
> > something like below?
> >
> > stmt.executeQuery( "SELECT COF_NAME, \
> > SALES FROM COFFEES " );
> >
> >
> > I know the code cannot be compiled, but is there any
> > substitution to the escape character above?
> >
> > Many thanks in advance.
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Kick off your party with Yahoo! Invites.
> > http://invites.yahoo.com/
> >
> >
> > ----------------------------------------------------------------------
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> >
>
> --
> -------------------------------------------------------------------------
>
> Tony Judy Paul,
>
> Software Engineer,
>
> AdventNet Development Centre (I) Pvt.Ltd,
>
> 13A, Kaashyap Enclave,
>
> Velacherry Main Road,
>
> Velacherry.
>
> Chennai-600042
>
> E-mail: [EMAIL PROTECTED]
>
> Phone: 2432414-419
>
> -------------------------------------------------------------------------
>
>
>
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]