Converting Objects and Simple Variables

One of the most common tasks you need to accomplish in Java is to convert information from one form into another. Several types of conversions you can do include

Note

When a method such as System.out.println() requires a string argument, you can use the + operator to combine several different types of information in that argument. As long as one of the things being combined is a string, the combined argument is converted into a string.

• Converting an object into another object

• Converting a simple variable into another type of variable

• Using an object to create a simple variable

• Using a simple variable to create an object

Simple variables are the basic data types you learned about during Hour 5 ...

Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.