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 trial
Dominik Flex
354 PointsJava - problem with method
Hello,
At workspaces I can start java Introductions.java without problems - printf("Hello"), when I am at Intellij IDEA and start java Introductions.java: NullPointerException. Where is the problem?
Thanks.
Dominik Flex
354 Pointsimport java.io.Console;
public class Introductions {
public static void main(String[] args) {
Console console = System.console();
console.printf("Hello!");
}
}
1 Answer
Philip Gales
15,193 PointsHere is what I would use.
public class Introductions {
public static void main(String[] args) {
System.out.println("Hello!");
}
}
There is even a shortcode. Type 'sout' and then press <tab> and it will type it for you.
Dominik Flex
354 PointsI have programmed 2 years in Java, System ... is shorter solution, but I want to know, why is problem, when I use Console bla bla :-)
Philip Gales
15,193 PointsPhilip Gales
15,193 PointsCan you share your code for the file?