Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Can an int array contain a short or byte?

  1. #1
    Junior Member
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Question Can an int array contain a short or byte?

    Edit: Sorry. I should post this in a different area. I'm looking for a delete button.... Can't find it yet.


    I was asked the following True/False question on a test.

    An array declared as an int can contain elements of different primitive types.
    True or False?

    I hated the question the moment I read it.

    For some background, the textbook said the following:

    "All values stored in an array have the same type (or are at least compatible)."

    The textbook also said:

    "A value stored in an array is sometimes called an array element...."

    What do you think? Is it true or false?
    "An array declared as an int can contain elements of different primitive types."


    Is 00001111 "contained in" 0000000000001111 if the array is composed of the latter "type" of data?
    Last edited by snyderthing; October 11th, 2018 at 01:59 PM.

  2. #2
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Can an int array contain a short or byte?

    Don't worry about it. A moderator will delete this post and move the old one to the appropriate forum.

    Regards,
    Jim

  3. #3
    Junior Member
    Join Date
    Oct 2018
    Posts
    13
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Can an int array contain a short or byte?

    Are there actually any moderators on this site? If so, why don't they delete the " Buy Registered and Unregistered Swiss, Austrian passports + id cards" posts that keep appearing daily lol?

  4. #4
    Member
    Join Date
    Sep 2018
    Location
    Virginia
    Posts
    284
    My Mood
    Cool
    Thanks
    0
    Thanked 38 Times in 36 Posts

    Default Re: Can an int array contain a short or byte?

    As far as I know there is one active moderator and he is on vacation. He will see your post when he returns. There are other issues he will probably want to deal with as well.

    Regards,
    Jim

Similar Threads

  1. [SOLVED] [Asking] Convert String to Byte Array
    By ardisamudra in forum Java Theory & Questions
    Replies: 8
    Last Post: October 30th, 2012, 09:58 AM
  2. Problem recreating an image from a byte array
    By Kalelovil in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 19th, 2012, 01:17 AM
  3. [SOLVED] Adding two byte/ short variables
    By ranjithfs1 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 26th, 2012, 04:31 AM
  4. Replies: 4
    Last Post: September 5th, 2010, 10:29 AM
  5. Convert Vector to Byte Array
    By perlWhite in forum Java Theory & Questions
    Replies: 0
    Last Post: August 25th, 2009, 05:45 AM