Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7068417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:19:16+00:00 2026-05-28T05:19:16+00:00

For the long data type, I can suffix a number with L to make

  • 0

For the long data type, I can suffix a number with L to make the compiler know it is long. How about byte and short?

As motivation, the following yields a type-mismatch error:

List<Short> a = Arrays.asList(1, 2, 3, 4);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T05:19:17+00:00Added an answer on May 28, 2026 at 5:19 am

    What you are actually talking about is an integer literal ( 1 ) versus a long literal ( 1L ). There is actually no such thing as a short or byte literal in Java. But it usually doesn’t matter, because there is an implicit conversion from integer literals to the types byte, short and char. Thus:

    final byte one = 1;  // no typecast required.
    

    The implicit conversion is only allowed if the literal is in the required range. If it isn’t you need a type cast; e.g.

    final byte minusOne = (byte) 255;  // the true range of byte is -128 .. +127
    

    There are other cases where an explicit conversion is needed; e.g. to disambiguate method overloads, or to force a specific interpretation in an expression. In such cases you need to use a cast to do the conversion.

    Your example is another of those cases.


    But the bottom line is that there is no Java syntax for expressing byte or short literals.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The long double data type can have these conversion specifiers in C: %Le,%LE,%Lf,%Lg,%LG (
How can I convert a NSString containing a number of any primitive data type
Short version: assuming I don't want to keep the data for long, how do
I'm trying to figure out syntax that supports unboxing an integral type (short/int/long) to
I have a long description field in a products table with a data type:
I am writing an app in Perl that requires long data type instead of
In C on a 32-bit system, which data type will store (and can therefore
I've been seraching for the data type of LONG CONTINUOUS in SQL Server Analysis
How can I convert a timespan datatype to a long ?
I have to work with strings which may contain Lat/Long data, like this: $query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.