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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:11:22+00:00 2026-06-10T15:11:22+00:00

I want to make a new variable with which i can do the following:

  • 0

I want to make a new variable with which i can do the following:

Variable v1 = 1;
Variable v2 = "Test";
Variable v3 = 7.31;

Is this possible, or is this impossible?

  • 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-06-10T15:11:24+00:00Added an answer on June 10, 2026 at 3:11 pm

    If you take advantage of auto-boxing (Java SE 5.0 and later) then every one of those can be stored in an Object (i.e. the base class of all Java types):

    public class foo {
        static public void main(String[] params) {
            Object v1 = 1;
            Object v2 = "Test";
            Object v3 = 7.31;
    
            System.out.println(v1 + " " + v1.getClass().getName());
            System.out.println(v2 + " " + v2.getClass().getName());
            System.out.println(v3 + " " + v3.getClass().getName());
        }
    }
    

    output:

    % java foo
    1 java.lang.Integer
    Test java.lang.String
    7.31 java.lang.Double
    

    This does not necessarily make it a good idea, though!

    The output shown above shows how although every variable was declared as an Object, their real class name is one more appropriate for their type. It’s only because every class in Java is derived from Object that the declarations can work that way.

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

Sidebar

Related Questions

I want to make a smart keyboard that can learn and save new words
I want to make a query using which I can check that URL which
I want to make new stackpanal from another stackpanal already made before but if
I don't want to make a new instance of Form1 in the class, and
I am new android app developer i want make app for tablets and phone
I want to make a function for a new datatype in Standard ML, the
I am new to .NET and ideally want to make several layers of abstraction
i'm new to gooogle map developing.i want to make a map as follows. http://edition.cnn.com/SPECIALS/world/arab-unrest/index.html
I want to make routing for form when submitting the form, $reportRoute = new
We are designing a new application for Android and we want to make it

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.