Skip to main content

Posts

Showing posts with the label java print

java print

Syntax of main method in java is    public static void main(String[]args)  before understanding about main method we have to understand that who is responsible for main method.if we write a simple program or write a simple java class without main method like      Test.java           class Test      {      } above program will compile successfully.for compilation of  java file use  javac tool  or  javac.exe  file. javac Test.java it means compiler checks only syntax of class that means compiler does not check the main method in the file or program,so that compiler is not responsible for main method in java. After successfully compilation of above program we have to run the generated byte code. java Test Error: Main method not found in class Test, please define the main method as:    public static void main(String[] args) So JVM...

system out println

System.out.println():-  System.out.println(“javaindore.blogspot.in”);   , will display message written in double quotes on the standard output device that is system screen or monitor. Here System is a java class, declared in lang package like java.lang.System, here java is main package and lang is a sub package. In java System class is declared as a public and final, due to public declaration everybody can happily access these class members but due to final declaration nobody can inherit this class or nobody can override System class methods. All the methods of System class are public and static so everyone can access all the methods using class name like classname.method. For example:   public static void exit (int)   is a method of System class then using  System. exit (0)   anyone can use. System class not provided public constructor so directly we cannot create object of System class. System class in java:-  ...