Sunday, March 22, 2020

first program in java

Steps to create a simple java program in Notepad

  • Open Notepad and create
class Hellojava
{
public static void main(String arg[])
{
System.out.print("HELLO");
}}


  • Create myprograms folder on  any drive (C:,D:)
  • Save the file with the class name like Hellojava.java inside the created folder 
  • Open cmd and type command  javac Hellojava.java
  • After compiling run the program using java Hellojava command   

1 Simple program to print A to Z


class AZ

{
public static void main(String arg[])
{
for(char i='A';i<='Z';i++)
System.out.println(" "+i);
}}

output:-


2. simple example to print A to Z 
class ab

{
public static void main(String arg[])
{
for(char i= 65;i< 91;i++)
System.out.print(" "+i);
}}

No comments:

Post a Comment