+ 3

How can you create a variable in java that can hold all data types or int and String?

27th Apr 2020, 11:49 PM
Divine Darkey
Divine Darkey - avatar
6 Answers
+ 2
You can do it in Java by using the "var" keyboard this works like python you don't have to define int or String or any other data type, or you can use Object class which works pretty much the same but it's a class with this you can for example create an array which will look like that: [int, char, String]
28th Apr 2020, 3:11 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 3
Eliya Ben Baruch thank you for the answer I really appreciate it, you have not taught me alone but Prabhat Ranjan also who says java does not have such a feature.
28th Apr 2020, 12:29 PM
Divine Darkey
Divine Darkey - avatar
+ 2
This feature is only supported in python and not in Java
27th Apr 2020, 11:51 PM
Prabhat Ranjan
Prabhat Ranjan - avatar
+ 2
So how can you write a program that collects users email address which usually contains symbols, numbers and alphabets?
28th Apr 2020, 12:01 AM
Divine Darkey
Divine Darkey - avatar
+ 2
By using strings But strings does not means that it can accept values of all data types. It is just a collection of characters
28th Apr 2020, 12:05 AM
Prabhat Ranjan
Prabhat Ranjan - avatar
+ 2
I now get it, it wasn't working at first thanks
28th Apr 2020, 1:23 AM
Divine Darkey
Divine Darkey - avatar