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: how can i use this function

  1. #1
    Junior Member
    Join Date
    Dec 2017
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how can i use this function

    i want use this function how can i do it?
    thx for help
    private static int[] print (int x) {
    but i need the int[] numbers

    this is my code
    package homeworks;
     
    import java.util.Scanner;
     
    public class ex1{
    public static void main(String[]args) {
    	Scanner scan = new Scanner(System.in);
    	int x = scanx(scan);
    	print(x);
     
     
    	scan.close();
       }
    public static int scanx (Scanner scan) {
    	System.out.println("ENTER A NUMBER");
    	int r = scan.nextInt();
    	while(r<=0) {
    		 r = scan.nextInt();
    	}
    	return r;
    }
    private static int[] print (int x) {
    	int[] arr = new int[x]; 
    	for(int i=0;i<x;i++) {
    		arr[i]=(int)(Math.random()*1000);
    		System.out.print(arr[i]);
    		System.out.print(" ");
    	}return arr;
    }
     
     
    }

  2. #2
    Member John Joe's Avatar
    Join Date
    Jun 2017
    Posts
    258
    My Mood
    Amused
    Thanks
    8
    Thanked 18 Times in 18 Posts

    Default Re: how can i use this function

    Please give an example for the desired output
    Whatever you are, be a good one

Similar Threads

  1. Help with five function calculator
    By catisch in forum What's Wrong With My Code?
    Replies: 10
    Last Post: October 12th, 2013, 02:50 PM
  2. Function in Function?
    By junxiqqq in forum Java Theory & Questions
    Replies: 5
    Last Post: May 18th, 2012, 08:05 PM
  3. need help with a function...
    By fallout87 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 2nd, 2011, 05:42 AM
  4. About the ackermann function...
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 25th, 2011, 09:24 AM
  5. Function of difference between two numbers
    By uplink600 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 13th, 2009, 05:57 AM