Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: I need join my code with the main metod, but i dont know how.

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I need join my code with the main metod, but i dont know how.

    package du1;

    import java.util.Scanner;

    public class Du1 {

    /**
    * Zde je metoda resici problem faktorialu
    * Doplnte spravne obsah metody.
    */
    public static int faktorial(int pom) {
    System.out.println("Zadejte číslo: ");
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    pom = 1;
    while (n > 1) {
    pom = pom * n;
    n = n - 1;
    }
    return pom;

    }

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {

    }
    }


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    36
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: I need join my code with the main metod, but i dont know how.

    call the method in main method if you want to use it. For example, add line in main method: int res = faktorial(10);

  3. The Following User Says Thank You to luck999 For This Useful Post:

    javapenguin (October 9th, 2011)

Similar Threads

  1. Replies: 4
    Last Post: July 25th, 2011, 06:12 PM
  2. My code have a simple error but i dont know how to solve it !!!
    By Blackhawk1993 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: March 17th, 2011, 01:12 PM
  3. Missing a line or two of code,b ut dont know what it is.
    By backdown in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 20th, 2011, 08:13 AM
  4. WHY this code dont work?
    By sibbe in forum Java Theory & Questions
    Replies: 7
    Last Post: December 9th, 2010, 09:47 AM
  5. [SOLVED] I dont know how to complete this code?
    By jwb4291 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 21st, 2010, 09:07 AM