[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

2 byte array representation of a string

Posted on 2004-11-12
2
Medium Priority
?
278 Views
Last Modified: 2010-03-31
Dear Experts,

In Modula programming labguage, any string (array of chars) can be mapped to a array of cardinal type.A cardinal type can hold 2 bytes.

So a string can be mapped to a array of 2bytes values.

In java, I can split the String into individual single bytes (String.getBytes()).

But I need to simulate the same functiionality as in modula.
i.e, i need to get the array of 2 bytes values of a string.

Could anybody suggest me the means?

Thanks in advance
Latha
0
Comment
Question by:slathakamatchi
2 Comments
 
LVL 92

Expert Comment

by:objects
ID: 12572361
A java char is two bytes

char[] chars = s.toCharArray();
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 300 total points
ID: 12574538
>>  need to get the array of 2 bytes values of a string.

You don't use getBytes () for that. You generally use getBytes () while transferring the data through a network using sockets, etc (just an example - there could be more).
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month20 days, 2 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question