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 trialHernan Cedillo
392 Pointshow is java basic any different from java with system.out.println():
I want better myself in java programming language. For the introduction i went ahead and tried compiling System.out.println("Hello world"); instead of console.printf("hello world"); I was wondering how different the syntax is?
2 Answers
Simon Coates
28,694 PointsSystem.out (a PrintStream) and System.in (an InputStream) work as a pair. A Console object is able to be retrieved from System.console, but may not be available in all environments (oracle state "Whether a virtual machine has a console is dependent upon the underlying platform"). The console object does input and output on a single object. The methods are documented at https://docs.oracle.com/javase/7/docs/api/java/io/Console.html . You're likely to use format, readLine, printf to begin with.
Console and System.out are simple to use. System.in is more complicated, i think. You often use a java.util.Scanner with System.in .
see https://www.programiz.com/java-programming/basic-input-output#input and https://stackoverflow.com/questions/4005378/console-writeline-and-system-out-println for more
Hernan Cedillo
392 PointsThank You very much
Hernan Cedillo
392 PointsHernan Cedillo
392 PointsSo learning Java Basics is no different than learning just Java with System.out.println(); right? When it comes to the algorithms and structures
Simon Coates
28,694 PointsSimon Coates
28,694 PointsWithin an introductory course, these are just ways to get information in or out. You might use them for a console/command line application, but a lot of java applications are either web applications or desktop applications (Swing, AWT). In either case, most of your input /output would be via different means. As such, I wouldn't worry too much for now.