?
Solved

byte[], Byte[], char[], Character[]

Posted on 2011-09-06
7
Medium Priority
?
393 Views
Last Modified: 2012-05-12
I would like to know about byte[], Byte[], char[], Character[]
How the primitives and wrappers are different esp with character and Byte etc.I was not clear on this concept. Thanks in advance
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
7 Comments
 
LVL 47

Accepted Solution

by:
for_yan earned 1336 total points
ID: 36492786
It is the same as with any other primitive types and their wrappers

byte is primitive

Byte is object wrapper around byte

char is primitive

Character is wrpper around char

one thing that in some
cases it is more convenient to opetarte
with oobjects which can be stored in Collections
can be test on equality to null, etc.

Another thing that these classes
have useful static mthods - say you could
produce byte form String
paarseByte(String s) , etc.

or check Cgharacter.isDigit() etc.


Look in the Byte Aand Character API



 
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36492791
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36492801
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Assisted Solution

by:dpearson
dpearson earned 664 total points
ID: 36493173
Also in Java a Character (or char) is representing a single Unicode character - which is generally a 16-bit value.

A Byte (or byte) is representing a single 8-bit byte.

So Bytes and Characters are very different concepts.

The difference between byte and Byte and the role of wrappers for_yan has already explained.

Doug
0
 
LVL 7

Author Comment

by:gudii9
ID: 36584426
>>>oobjects which can be stored in Collections


can not we store prmitives in collection. please advise
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36584450

Collections can contain only objects, they can not contain primitives directly,
though autoboxing makes look so as if it stores the prinmitives

You can write:
        ArrayList<Integer> arint = new ArrayList<Integer>();
       
        arint.add(5);

But in fact compiler makes out of it:

 ArrayList<Integer> arint = new ArrayList<Integer>();
       
        arint.add(new Integer(5));

So primitives cannot be elements of collections


0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 1336 total points
ID: 36584462


 ArrayList<int> arint1 = new ArrayList<int>();

This will cause compiler error: Type argument cannot be of primitive type
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
A solution for Fortify Path Manipulation.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 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