Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-09-06
7
Medium Priority
?
397 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
Industry Leaders: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

636 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