Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAnastasia Ponomarenko
11,802 PointsMixed types in one array
So if I want to create an array of strings, it's: String[] myArray = {"Jane", "Joe"} How would I declare an array that can have items of different types, e.g. both string and boolean, e.g. {"Jane", true, "Joe", true}? Is it possible in Java?
1 Answer
Kian Tahsini
7,138 PointsThis isn't possible through Java, as in there isn't a data type that allows for mixed types. You can get around this though. Maybe try converting data values into strings and placing them into a string array (and then trying to convert them back).