5 Replies Latest reply: Oct 30, 2012 10:54 AM by gimbal2 RSS

    void

    971422
      what is the reason for using "void"in java language...
        • 1. Re: void
          gimbal2
          In stead of peppering this forum with basic knowledge questions, why don't you invest in a good book on Java in stead? You are wasting your time if you have to ask about every tiny little thing you run into and then wait for an answer.

          You know about methods right? A method can have a return type. You would use 'void' when you want to create a method without a return type.
          // notice the 'return' statement, int return type
          public int add(int a, int b){
            return a + b;
          }
          
          // no return statement, void return type
          public void sayHello(){
            System.out.println("hello!");
          }
          • 2. Re: void
            971422
            hey gimbal2 or whatever i m not wasting my time,for your kind info... somebody told me to check this forum.... i m referring a good book based on java...so stop giving lectures to others.
            • 3. Re: void
              rp0428
              >
              what is the reason for using "void"in java language...
              >
              For questions about the language features and what they do you should refer to the Java Language Specification - the main download is at
              http://docs.oracle.com/javase/specs/

              See section 8.4.5 Method Return Type
              http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.4.5
              >
              8.4.5. Method Return Type
              The result of a method declaration either declares the type of value that the method returns (the return type), or uses the keyword void to indicate that the method does not return a value.
              • 4. Re: void
                somebody told me to check this forum....
                That would mean that you need to spend a considerable amount of YOUR time to read the contents of these forums. There are years and years of information here already. You don't need to post any new questions that ask what has already been posted +... particularly when they are fundamental topics that are in the documentation.+
                i m referring a good book based on java
                You could find that so much faster if you would just use your favorite Internet search site (such as Bing, Google, Baidu).

                .
                Edit:
                By the way, your duplicate post of this question has been removed from the forum.

                Edited by: rukbat on Oct 30, 2012 11:22 AM
                • 5. Re: void
                  gimbal2
                  968419 wrote:
                  hey gimbal2 or whatever i m not wasting my time,for your kind info... somebody told me to check this forum....
                  And you just do what others tell you? You don't think for yourself?
                  i m referring a good book based on java...
                  That would actually be a useful question to ask in a forum. Although as Rubkat already mentioned in a more general way, that information has been passed out many times already. I did myself a couple dozen times at least.
                  so stop giving lectures to others.
                  I don't lecture, I pass out advice which you are free to accept or not. Advice which will prevent you from getting less nice answers if you keep continuing abusing the forum as your personal information service. As you can see from my post count, I've been around here for a while now. I've seen many people before you go into various emotional states because of their own actions. I try to prevent that from happening.

                  But hey, nice attitude.