About 50 results
Open links in new tab
  1. How do you know a variable type in java? - Stack Overflow

    Let's say I declare a variable: String a = "test"; And I want to know what type it is, i.e., the output should be java.lang.String How do I do this?

  2. java - Long vs Integer, long vs int, what to use and when? - Stack …

    May 2, 2011 · Java.util.collections methods usually use the boxed (Object -wrapped) versions, because they need to work for any Object, and a primitive type, like int or long, is not an Object. Another …

  3. How to check type of variable in Java? - Stack Overflow

    Oct 22, 2010 · 142 Java is a statically typed language, so the compiler does most of this checking for you. Once you declare a variable to be a certain type, the compiler will ensure that it is only ever …

  4. java: How can I do dynamic casting of a variable from one type to ...

    I would like to do dynamic casting for a Java variable, the casting type is stored in a different variable. This is the regular casting: String a = (String) 5; This is what I want: String theT...

  5. What variable type can I use to hold huge numbers (30+ digits) in java?

    Is there a really large variable type I can use in Java to store huge numbers (up to around forty digits)? long 's maximum value is 9223372036854775807, which is 19 digits -- not nearly large enough.

  6. How to Change the Type of a Variable in Java? - Stack Overflow

    Nov 9, 2023 · 1 I am working on a Java project and have encountered a situation where I need to change the type of a variable during runtime. Is there a way to do this in Java? void doSmth(){ String …

  7. java - How do you format and print multiple data types in single ...

    Sep 10, 2019 · Not a Java expert but have you tried System.out.print()? You can print both in one line with this method but you'll need to call it twice for each variable.

  8. How can I make a Java function that accepts any type of variable ...

    May 1, 2020 · I would like to make a function that can accept any incoming variable, regardless of type (int, double, String or other objects), and then possibly determine the type of variable and act …

  9. Can you have a multiple-type variable declaration in Java?

    Apr 13, 2013 · Create a union interface which extends the others and declare a variable of that type. I would prefer not to do either of these because 1 is not type-safe and 2 can mean you quickly end up …

  10. Var keyword in Java - Stack Overflow

    Jul 24, 2020 · With Java 10 or +, we can use var keyword for declaration. At initialization, a type is going to be inferred by the compiler. What happens when the class I instantiate and assign to the variable …