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 99297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:21:38+00:00 2026-05-11T00:21:38+00:00

So I’m learning java, and I have a question. It seems that the types

  • 0

So I’m learning java, and I have a question. It seems that the types int, boolean and string will be good for just about everything I’ll ever need in terms of variables, except perhaps float could be used when decimal numbers are needed in a number.

My question is, are the other types such as long, double, byte, char etc ever used in normal, everyday programming? What are some practical things these could be used for? What do they exist for?

  • 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. 2026-05-11T00:21:39+00:00Added an answer on May 11, 2026 at 12:21 am

    With the possible exception of ‘short’, which arguably is a bit of a waste of space– sometimes literally, they’re all horses for courses:

    • Use an int when you don’t need fractional numbers and you’ve no reason to use anything else; on most processors/OS configurations, this is the size of number that the machine can deal with most efficiently;
    • Use a double when you need fractional numbers and you’ve no reason to use anything else;
    • Use a char when you want to represent a character (or possibly rare cases where you need two-byte unsigned arithmetic);
    • Use a byte if either you specifically need to manipulate a signed byte (rare!), or when you need to move around a block of bytes;
    • Use a boolean when you need a simple ‘yes/no’ flag;
    • Use a long for those occasions where you need a whole number, but where the magnitude could exceed 2 billion (file sizes, time measurements in milliseconds/nanoseconds, in advanced uses for compacting several pieces of data into a single number);
    • Use a float for those rare cases where you either (a) are storing a huge number of them and the memory saving is worthwhile, or (b) are performing a massive number of calculations, and can afford the loss in accuracy. For most applications, ‘float’ offers very poor precision, but operations can be twice as fast — it’s worth testing this on your processor, though, to find that it’s actually the case! [*]
    • Use a short if you really need 2-byte signed arithmetic. There aren’t so many cases…

    [*] For example, in Hotspot on Pentium architectures, float and double operations generally take exactly the same time, except for division.

    Don’t get too bogged down in the memory usage of these types unless you really understand it. For example:

    • every object size is rounded to 16 bytes in Hotspot, so an object with a single byte field will take up precisely the same space as a single object with a long or double field;
    • when passing parameters to a method, every type takes up 4 or 8 bytes on the stack: you won’t save anything by changing a method parameter from, say, an int to a short! (I’ve seen people do this…)

    Obviously, there are certain API calls (e.g. various calls for non-CPU intensive tasks that for some reason take floats) where you just have to pass it the type that it asks for…!

    Note that String isn’t a primitive type, so it doesn’t really belong in this list.

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

Sidebar

Ask A Question

Stats

  • Questions 168k
  • Answers 168k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Found the fix for this problem here: http://www.west-wind.com/WebLog/posts/601200.aspx It looks… May 12, 2026 at 1:41 pm
  • Editorial Team
    Editorial Team added an answer I found the solution! Over-ride processStatusLine and check for status… May 12, 2026 at 1:41 pm
  • Editorial Team
    Editorial Team added an answer When you want all concrete instances of a type to… May 12, 2026 at 1:41 pm

Related Questions

In order to apply a triggered animation to all ToolTip s in my app,
this is what i have right now Drawing an RSS feed into the php,
I have text I am displaying in SIlverlight that is coming from a CMS
I have a French site that I want to parse, but am running into
So I'm getting a new job working with databases (Microsoft SQL Server to be

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.