Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: why String.getBytes() truncates byte[]
On Tue, 28 Sep 2004 14:00:57 +0530, Madhur Ahuja wrote:
> Can the length of primitive data types like byte[], be dynamically
> reduces in java. For ex in the following code

No.

mname is a *reference* to a byte array. Initially it refers to an
array of 20 bytes that you created with "new". After assigning the
return from String.getBytes(), it refers to a *different* byte array,
and the initial array becomes eligible for garbage collection.

There is another detail that you take for granted: the array returned
by String.getBytes() might not be the same length as the String.
Depending on the character encoding used, it could be the same or
longer. Since you didn't specify an encoding, the system default is
assumed.

/gordon

--
[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

Report this thread to moderator Post Follow-up to this message
Old Post
Gordon Beaton
09-28-04 02:04 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:34 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.