About 457,000 results
Open links in new tab
  1. String datatype in java - Stack Overflow

    Apr 19, 2011 · String is class in java.lang pack but in.java al classes are also considered as data types so we can take string data type also.. We can.cal class is user definednd data type. This is because a user can create a class. String a; A is variable f the data type "string "

  2. Java data types - Stack Overflow

    Sep 12, 2015 · The String class is not technically a primitive data type, it is included Java API (You can read a little more about it, always useful!). So, the biggest difference between int and String, is only that one is a Java Class, and the other is not. this is a list of all the primitives in Java (all in lower case):

  3. How to parse a String variable into any data type in Java?

    There are only a few types of variable to which a String reference is assignable, String, Object, Serializable, Comparable, and CharSequence. Many, but not all, classes have ways of producing an object instance based on a String. In some cases, including BigDecimal, there is a constructor that takes a String representation of the new object's ...

  4. Java Data Types: String and Array - Stack Overflow

    The linguistic distinction between arrays and other object types is that the type of an array is not a normal Java class. For example: Array types are declared with a different syntax to normal classes. Array instances are created with a different syntax to normal class instances. Array types cannot be named at the Java source code level.

  5. java - Why is there no primitive type for String? - Stack Overflow

    Jul 15, 2013 · The ONLY logical answer found to a straight question: Because of memory allocation issues. an int or a float type requires a specific memory size, but a string (sorry, String) is of a variable length made up of a undetermined (at declaration time) length of memory.

  6. java - Is String a class or data type or both? - Stack Overflow

    Dec 18, 2017 · A Java String is simply a class - BUT as the JavaDoc documentation of String states: "..All string literals in Java programs, such as "abc", are implemented as instances of this class..." So the language literal "abc" is another way of saying String.create("abc") if there would be such a method. The compiler itself manages these literals.

  7. java - Hashmap holding different data types as values for instance ...

    Jan 30, 2013 · I need to create a hashmap with key as integer and it should hold multiple values of different data types. For example if the key is msg id and the values are message of type string timestamp of t...

  8. What is the best way to convert any primitive data type to string

    Dec 26, 2011 · Similarly, one of the easiest way to convert primitive datatypes to String is to use the toString() method with the datatype object of the element to be converted. String str = Double.toString(d); // Convert double to String String str = Long.toString(l); //Convert long to String String str = Float.toString(f); //Convert float to String

  9. Difference between "char" and "String" in Java - Stack Overflow

    Jan 12, 2015 · String is instead a reference type, thus a full-blown object. It can hold any number of characters (internally, String objects save them in a char array). Primitive types in Java have advantages in term of speed and memory footprint. But they are not real objects, so there are some possibilities you lose using them.

  10. java - Trying to count the number of data types in a string - Stack ...

    Jun 15, 2022 · So at the input, a string contains different types of data. Basically, this is a string, int, and float. I check types through Float.parseFloat() and Integer.parseInt() . the Integer.parseInt() works correctly, yet Float.parseFloat() includes all the digits that are checked.