Java programming language main method question?

Hello everyone I am quite new to the Java programming language and I have a question here concerning my main method. As you can see I am calling 4 others methods with my main method. What does the null mean after I call the method? I really don't understand is significance, what else could go there besides null?
public static void main(String[] args)
          int cansPerPack = 6;
          System.out.println(cansPerPack);
          int cansPerCrate = 4* cansPerPack;
          System.out.println(cansPerCrate);
          have_fun(null);
          user_input(null);
          more_java(null);
          string_work(null);
     }Edited by: phantomswordsmen on Jul 25, 2010 4:29 PM

phantomswordsmen wrote:
..As you can see I am calling 4 others methods with my main method. 'Your' main method? Your questions indicate that you did not write the code, who did?
..What does the null mean after I call the method?.. 'null' is being passed as an argument to the method, so there is no 'after the method' about it.
..I really don't understand is significance, what else could go there besides null? That would depend on the method signatures that are not shown in the code snippet posted. This is one of many reasons that I recommend people to post an SSCCE *(<- link).*
BTW - method names like have_fun() do not follow the common nomenclature, and are not good code for a newbie to study. The code should be put to the pointy end of your sword.

Similar Messages

  • Calling one java program (with main method) from another

    Hello,
    How can I start another java program from one? Lets
    say I want Second.java to start by calling it from
    First.java. How do I do it? The two programs are given
    below. Any help is appreciated.
    Thanks,
    Amanda
    First.java
    import java.io.*;
    import java.lang.reflect.*;
    public class  First
         public static void main(String[] args)
              Process theProcess=null;
              System.out.println("Hello World from First.java!");
              String second=new String("Second.java");
              //System.load(second);
              //Runtime.getRuntime().load(second);
              try
                   theProcess=Runtime.getRuntime().exec( "Second.java"
                   System.out.println("after exec");
              catch (IOException ioe)
                   System.out.println(">>IOException thrown in
    First.java while calling
    Second.java."+ioe.getMessage());
    Second.java
    public class  Second
         public static void main(String[] args)
              System.out.println("Hello World from Second.java!");
    }

    Stop posting here. The crosspost remark was to alert others that there is a duplicate topic - all answers should be centralized in one so as to not waste people's time duplicating answers when they don't see both topics and the answers therein.

  • Java Programming Language questions...???

    Hi everybody....
    Can I post here my questions about Java Programming Language....or only to to the relevant Sun's forum....http://forum.java.sun.com/index.jspa???
    My greetings,
    Simon

    Simon,
    sure, the worst thing that could happen is that people point you to the SUN forum. Usually this forum answers general Java questions.
    Frank

  • Java programming language uses call by reference for objects?

    Is Java programming language uses call by reference for objects?

    Yes. You make calls to an object via itsreference.
    No.Yes, you're referring to passing a reference into a
    method in which case the value of the
    reference is passed.I believe the OP is using the term "call by reference" to mean "pass by reference." The two are interchangable, AFAIK. So, while "making calls to an object via its reference" is correct, I don't believe it's germane to the question.

  • Is it possible to run the java program without main?

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    Ramya

    Hi,
    Is it possible to run the java program without main?
    if anybody know please tell me, how it is possible.
    Regards,
    RamyaWhy do you ask? It sounds like an odd question. Your program can be an applet and it doesn't need a main method in that case.
    Kaj

  • Java programming language

    What are the major differences between Java programming language and HTML or XML and why is it better?

    Thanks for your response but I am dumb when it comes
    to this stuff. I am taking an information systems
    class and the professor is asking us to list three
    different items that makes Java different from other
    programming languages used and I thought posing that
    question to this form would provide me the
    information I was looking for. The text does not
    state the answer he is looking for. Any help would be
    great.
    ThanksI'd assume your professor is asking you to do something called "research" where you go read stuff about it/them. What you're doing is called "just ask someone to tell some answers to turn in as my own", or in other words, "cheating".

  • Syllabus/Topics for Sun Certified Instructor for Java Programming Language

    Hi,
    What is the Syllabus/Topics for Sun Certified Instructor for Java Programming Language ?
    At the following link
    http://www.sun.com/training/catalog/instructor/java.html
    detailed syllabus is not there.
    I am unable to find the details in Sun site even after search through google.
    Please help in this regard.
    Thank you for your kind consideration.

    Sir,
    thank you for your response.
    technic  wrote:
    I'm not sure what you mean by Syllabus/Topics?For SCJA/SCJP/SCWCD/SCBCD/SCDJWS/SCMAD/SCEA
    I am able to find the detailed syllabus for the exam by clicking on the respective certification link at the following link
    http://www.sun.com/training/certification/java/index.xml
    for example: for SCJP,
    http://www.sun.com/training/certification/java/scjp.xml
    http://www.sun.com/training/catalog/courses/CX-310-065.xml
    these links are providing exam objectives, number of questions, exam duration , fee details etc.
    But for
    Sun Certified Instructor for Java Programming Language Course (SL-275)
    I am unable to find such details exam objectives (syllabus), no. of questions, exam duration, etc.,
    even, the following link
    http://www.sun.com/training/certification/objectives/index.xml
    is providing details of all other certifications except
    Sun Certified Instructor for Java Programming Language Course (SL-275)
    thank you for your kind consideration.

  • WLS JMS supports the clients developed by using non-java program languages,such as,c++,VB...

              WLS JMS supports the clients developed by using non-java program languages,such
              as,c++,VB?
              

    The short answer is yes. This is a frequently asked question. I
              suggest searching this newsgroup in google using terms like "C++",
              "IIOP", ".NET", "JCOM".
              Note also that WL 8.1 (now out in beta) contains a thin java client
              (something like 0 or 300K without JMS, 700k with. The 0K client comes
              from leveraging WL's IIOP support.)
              Tom, BEA
              jerry8006 wrote:
              > WLS JMS supports the clients developed by using non-java program languages,such
              > as,c++,VB?
              

  • How to create an Oracle DATABASE through Java Programming Language.. ?

    How to create an Oracle DATABASE through Java Programming Language.. ?

    Oracle database administrators tend to be control freaks, especially in financial institutions where security is paramount.
    In general, they will supply you with a database, but require you to supply all the DDL scripts to create tables, indexes, views etc.
    So a certain amount of manual installation will always be required.
    Typically you would supply the SQL scripts, and a detailled installation document too.
    regards,
    Owen

  • The Java Programming Language (Javac.exe, java.exe) source code.

    Where can I get the java programming language source code ?
    Ernest Keshi
    [email protected]

    Check the 'Downloads' dropdown menu here at the top navigation bar.

  • Java Programming Language Answers

    Hi,
    My business is to teach Java to legacy engineers. I'd like to use a book "Java Programming Language" as one of materials. This book contains number of excellent excercises,but without answers. I found a Web page of answers which is http://java.sun.com/docs/books/javaprog/firstedition/answers/, but this page covers Chapter 1 to 14 and appendix. This book has Chapter 1 through 20. I would gratefully appreciate if someone tell me where answers for Chatpter 15 to Chapterr20.
    Thanks and Regards,
    Shintaro Sekine
    [email protected]

    It should be no problem if you give them your own answers.
    When you couldn't give right answers for a few of them, Mr. jverd et al would
    help you on this forum.

  • Main method question in java, please help

    Guys I have looked all over the internet, and cannot understand any of these questions: I would really appreciate any help on them. The first, and most important thing I would like to know is, what is static: what is a static int, or a static main method? Why is this necessary, and what does it do? Could you please provide an example? Also, why is String[] args necessary within the parameters of the main method? Is this so that it can execute it? Last thing is: objects. Where can I learn about them? I know they are made with the new operator, but don't understand their use? Could you explain why they are useful? Can you give them values? and how do they relate to the dot operator? After these are answered, I will be so happy because I will feel like I actually know a little bit. Right now, I'm just confused... Thank you so, so much in advance!

    The first, and most important thing I would like to know is, what is static'static' means that the item concerned is associated with the class itself rather than an instance: so, it is accessible to all instances.
    Could you please provide an example?
    public static void main(String[] args)is an example, but you knew that. I don't really understand the question.
    Also, why is String[] args necessary within the parameters of the main method?'args' receives the arguments you type on the command line after the class name or jar name, depending on how you invoke the application.
    This is all covered in the documentation, which you should read before asking further questions.
    Last thing is: objects. Where can I learn about them?If you don't know about objects you're not going to learn about them by asking questions on a forum. It's far too large a topic. Get yourself a book.

  • Beginner - class & main method question

    Hello, I am still really new to OOP and Java. I came across an example in the book I am using that threw me for a loop.
    ex.
    class MyClass {
    public static void main(String [] args) {
    int x = 42;
    MyClass y = new MyClass();
    int z = y.go(x);
    int go(int arg) {
    arg = arg * 2;
    return arg;
    what I am confused about is the creation of a new class that contains the main method (MyClass y = new MyClass()), wouldn't this create a new class that also has a main method? Or is this the kind of code I will never encounter outside an example in a book and shouldn't worry about it :-)
    Thanks

    Since the main method is static, it would be invoked through MyClass.main(...). Note that this is not actually creating an object, just calling a static method.
    Creating an object is an entirely different story. MyClass mc = new MyClass(); instantiates a new object of the class MyClass. You couldn't do mc.main(...) because main is static. You can call things such as mc's go() method because they are not static and thus belong to objects of that class, rather than the class itself.
    ...Or something. That all made sense in my head, but if it didn't make sense to you just tell me.

  • How to download Java Programming Language..

    hey lol im a real idiot, i cant find which one of the several million downloads contains the Java language programming tools...
    can anyone help me? i wanna get started coding and i cant til i have the program =)

    Go to Sun's main page: http://java.sun.com/ Across on the right there is a section
    headed "Popular Downloads". Choose the first option "Java SE".
    From there you should click the third download button, "JDK 5.0 Update 7". Accept
    the license, answer some question about your operating system, and you're done.
    Probably you should pick up a copy of Sun's tutorial - so you have something to
    do with the software once you've downloaded it. From the same "Popular
    Downloads" list choose "Tutorials", then "JavaSE Tutorial and Resources".
    You will end up here: http://java.sun.com/javase/reference/tutorials.jsp
    There's a "Download" tab for the tutorial.

  • Console Java Program: Keyboard I/O Question

    Ok,
    I'm programming a cute Maze game in Java, you see. Now, I am coding the class that will take input from the user and feed it to my "game engine"..heeh
    I'm trying to use the InputStreamReader class to take input from console (keyboard).
    Problem is, InputStreamReader won't "take" input unless the player hits the enter key to complete the input. However, I don't want the player to have to hit enter, imagine playing Quake where instead of just hitting w to move forward, you've got to hit w, and then enter, and then w, and then enter, etc.
    Is there a class, method, or way to do keyboard input so that my program will just read the next key pressed , no matter what it is, and use it as input?
    Here's some of my code:
    import java.util.*;
    import java.io.*;
    import java.lang.*;
    class MannyMaze
    public static void main(String[] args) throws Exception
    //code needed for keyboard input
    InputStreamReader console = new InputStreamReader(
    new DataInputStream(System.in));
    int c;
    for(int i = 0; i < 10; i++)
    System.out.print("input something: ");
    c = console.read();
    System.out.println("You inputted: " + c);
    Now I'd like this to prompt the user to input something, and then "take" it as input on the next key pressed, without pressing enter.
    However, as it is now, the user has to press enter after input to get it to do something.
    Help!
    avataR
    http://plaza.ufl.edu/avatar38

    Did you try a KeyListener?
    They're designed to work in GUI-Apps, but perhaps they
    will work with console-progs too.To add a key listener he would have to add a Component to a console prog. I don't think that would work because the program won't know its client area to listen for keystrokes like it does with a jframe for instance. But that brings up the question as to why wouldn't you write this program in a swing environment that would easily provide you with mouse and key listeners to do just what you want.

Maybe you are looking for

  • Concept of Abstraction and Polymorphism

    Hi friends, I'm just new to Java.I studied a little bit of C, I'm currently studing VB and Java. There are one or two concepts in Java that are very hard to grasp for me. The first is abstraction and the second is polymorphism. Can anybody outline to

  • Can I backup my iTune music library to an external drive and install on a new computer?

    Can I backup my iTune library to an external drive and reinstall on a new computer? To use disks I need 29 to do this.

  • Gnome 3.2 suspend with status menu: screen is not locked after wakeup

    Locking the screen with gnome-screensaver-command --lock or with the lock screen option from the status menu works fine. However, when the suspend from the status menu is used, although it does seem to go into lock mode before it suspends (the screen

  • Using time machine intermittently

    I have no need to have my files backed up every hour or two. So I turned off my backup drive with a reminder to backup once a week. I now turn on the backup drive, but see no way to initiate a backup. How do I now access Time Machine to do another ba

  • Installing ODBC/JDBC on Linux

    Anyone know of a quick method to install the necessary drivers for DBI on Linux. I wish to connect to an NT Oracle DB from my Linux box using perl...