Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7808431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:08:02+00:00 2026-06-02T03:08:02+00:00

I am trying to learn Java now and this is the hello world program

  • 0

I am trying to learn Java now and this is the hello world program and it already have started to baffle me. I am used to python and I found this tutorial (ebook) simple and concise for programmers who have python background.

Hello world program in Java from the book:

public class Hello {

public static void main (String[] args) {

     System.out.println("Hello World!");
}
}

As the book says, the equivalent code for this in python is:

class Hello(object):
  @staticmethod
  def main(args):
     print "Hello World!"

I completely understand the python code. However, I have a problem with Java code and I want to be clear before I proceed further so that I get the root knowledge of language in my brain.

The book says (as copied from book):

…we have one parameter. The name of the parameter is args however,
because everything in Java must have a type we also have to tell the
compiler that the value of args is an array of strings. For the moment
You can just think of an array as being the same thing as a list in
Python. The practical benefitt of declaring that the method main must
accept one parameter and the parameter must be a an array of strings
is that if you call main somewhere else in your code and and pass it
an array of integers or even a single string, the compiler will flag
it as an error.

This does not make any sense to me. Why can I not pass anything since my function doesn’t require anything? What happens if I just pass (String args).

Since I am completely newbie to Java, please bear with me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:08:04+00:00Added an answer on June 2, 2026 at 3:08 am

    As you know, Python uses “duck typing”: it doesn’t matter what type something is, only what it can do. As a result, you never need to declare types for your variables.

    In Java, that’s not true: every variable has a declared type, and the compiler enforces that type. Trying to store, for example, a String reference in an int-declared variable will produce a compile-time error. Proponents of duck typing claim that this decreases flexibility, but strong-typing enthusiasts point out that compile-time errors are easier to fix than run-time bugs.

    But the same is true of your method arguments. Since your method requires an argument of type String[], it must be provided an argument of type String[]. Nothing else will do.

    Fortunately, since it’s the main method, the Java interpreter takes care of passing in an argument: specifically, an array of the command-line args with which your program was executed. If you’d like to ignore it, feel free. Your program will run just fine without paying attention to the argument, but it’s invalid if one isn’t passed in.

    (By the way, if this were any method but the main method, you’d be free to declare it with whatever argument types you’d like, including no arguments at all. But since the Java interpreter will be passing in an array of the command line arguments, this particular method must be prepared to accept them.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Few hours ago I have started to learn java socket comunication. Now I'm trying
Right now i am trying to learn more about java threading, and i have
I've developed in Java in the past, and now I'm trying to learn Grails/Groovy
I am trying to learn a java-based program, but I am pretty new to
I'm trying to learn web development in Java and, from what I have seen
I'm trying to learn java from bottom up, and I got this great book
I'm trying to learn Erlang, coming from a C++/Java background. This forces me to
i know virtually no java but i'm trying to learn some for this project.
I'm trying to learn Java right now and I've jumped in the deep end
I was trying to implement a Matrix.class to learn some Java. Right now, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.