• Skip to main content
  • Skip to primary sidebar

Founder at work

Master the skills to create and launch your next SaaS company

  • About Me
  • Reviews
  • Resources
  • Community
  • Contact
  • Lessons
  • Series
  • Search
  • Login

Ever wanted to know the logic behind hello world program in java?

October 17, 2012 by Rick Hernandez Leave a Comment



        
package cutnpaste; //package name 
        
public class HelloWorld 
{

    public static void main(String[] args) 
    {
        //initalization
        int age;
        String Message = "What is Your Name";
        String GiveAge = "Enter your age: ";
        String Name = "";
                
        Keyboard kbd = new Keyboard (); // creates an instance of Keyboard and names it kbd
        
        System.out.println(Message); // prints message string
        
        Name = kbd.readWord(); // reads a word from keyboard

        System.out.println(GiveAge);
 
        age = kbd.readInt(); // creates an instance of kbd and reads an int

        // Prints out the Name String
        System.out.print(Name);
      
        
        if (age>17)
        {
            System.out.println("You are leagal");
        }
        
        if (age>17) // if else statement
        {
            System.out.println("Time to vote");
        }
        else
        {
            System.out.println(" You can NOT Vote");
        }
        
        while (age < 100) //while loop from age to 99
        {
            System.out.println("Age is:"+ age);
            age = age +1; //counter
            
        }//end of loop
        
              
    }// end of main
}// end of HelloWorld Class

Rick Hernandez

I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)

Related

Filed Under: Java, Programming

Primary Sidebar

Learn How To Take Your Idea And Convert It Into An App From Scratch Even If You Have Never Written A Single Line Of Code.

  • How to Find Your Next Great App Idea
  • The Secret To Getting PAID To Build Your Own App
  • How To Create Your App (SaaS, Mobile, VR, AR, Game)
  • How To Monetize Your Apps
Learn More
4.82 Ratings

Copyright © 2025 · JSecademy Blog Theme on Genesis Framework · WordPress · Log in