Results 1 to 4 of 4
  1. #1
    Wasp is offline Member
    Join Date
    Nov 2016
    Posts
    32
    Rep Power
    0

    Default Method Undefined Type

    I am using eclipse. My methods not working i dont know why. Eclipse message "Description Resource Path Location Type
    The method diziYaz(int[]) is undefined for the type Driver Driver.java /bubleShortDizi/src/bubleShortDizi line 12 Java Problem"
    Description Resource Path Location Type
    The method randomDoldurDizi(int[]) is undefined for the type Driver Driver.java /bubleShortDizi/src/bubleShortDizi line 11 Java Problem


    Java Code:
    package bubleShortDizi;
    
    import java.util.Scanner;
    
    public class Driver {
    	public static void main(String[] args) {
    		Scanner girdi = new Scanner(System.in);
    		System.out.println("Dizi Satırını Giriniz");
    		int index = girdi.nextInt();
    		int[] dizi = new int[index];
    		randomDoldurDizi(dizi);
    		diziYaz(dizi);
    
    	}
    
    }
    Java Code:
    package bubleShortDizi;
    
    import java.util.Random;
    
    public class Methods {
    	Random random = new Random();
    
    	void randomDoldurDizi(int[] gelenDizi) {
    		for (int i = 0; i < gelenDizi.length; i++) {
    			gelenDizi[i] = random.nextInt(99) + 1;
    		}
    	}
    
    	void diziYaz(int[] gelenDizi) {
    		for (int i = 0; i < gelenDizi.length; i++) {
    			System.out.println(gelenDizi[i]);
    		}
    	}
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Method Undefined Type

    Exactly as the message says.
    Those two methods do not exist in the Driver class.

    They do exist in the Methods class, but you would need to create a Methods object and use that to call those methods.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Wasp is offline Member
    Join Date
    Nov 2016
    Posts
    32
    Rep Power
    0

    Default Re: Method Undefined Type

    I copy methods in driver java problem solved. So i cant use in same folders class methods? I need to create object? And thank you for answer :)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Method Undefined Type

    Java is object oriented, so it's all about creating objects.
    You could have made the methods static, but you still would have had to call them using the Methods class (Methods.diziYaz() for example).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 09-27-2013, 01:09 AM
  2. Replies: 7
    Last Post: 03-29-2012, 09:26 AM
  3. Replies: 3
    Last Post: 11-18-2011, 08:15 AM
  4. Replies: 2
    Last Post: 05-07-2010, 11:02 PM
  5. Replies: 0
    Last Post: 05-27-2009, 04:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •