+ Reply to Thread
Results 1 to 3 of 3

Thread: Abstract method(SIMPLE VERSION)

  1. #1
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,852
    Blog Entries
    4
    Rep Power
    49

    Abstract method(SIMPLE VERSION)

    Hey hey C.C, let's have fun with abstract methods, well not really. Okay let's go on!

    We are going to use an array and create an abstract method to print in "our" own numbers in the array index list, anyways let's check out.

    Code:
    public class abstractmethod {
    	public static void main(String [] arg) {
    		
    		double d[] = new double[10];//We make an array with a index list containing with the numbers of 0-9
    		
    		func(d,5,9,2.3);//Our mission, d(the array) in index 5 and 9 enter in the value 2.3(BUT, this will not work out of the box, yet !) 
    		for(double q : d)//Looping through the array
    			System.out.println(q);//Printing the array's index numbers value one by one.
    		
    	}
    	protected static void func(double x [], int start, int end, double i) {//our abstract method. We start with using the function int start is connected to 5 and ends in 9, double i is the new output of our new array index list 
    		for(int y=start-1; y<end; y++)//we loop through the array to copy in the value 2.3
    			x[y]=i;//connect the whole old array with our new "array"(now it is one)
    	}
    }
    The output will be, note that 0.0 is the empty array index numbers we created from the start. We have only added value in the 5 to the 9. So that's all !!
    Code:
    0.0
    0.0
    0.0
    0.0
    2.3
    2.3
    2.3
    2.3
    2.3
    0.0

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    Re: Abstract method(SIMPLE VERSION)

    My only recommendation I have is make your comments easier to read (so they dont scroll off the page).

    Code:
    public class abstractmethod {
    	public static void main(String [] arg) {
    		
    		//We make an array with a index list 
    		//containing with the numbers of 0-9
    		double d[] = new double[10];
    		
    		//Our mission, d(the array) in index 5 and 9
    		//enter in the value 2.3(BUT, this will not work
    		//out of the box, yet !) 
    		func(d,5,9,2.3);
    
    		//Looping through the array
    		for(double q : d)
                   ////Printing the array's index numbers value one by one.
    			System.out.println(q);
    		
    	}
    
    	//our abstract method. We start with using the function 
    	//int start is connected to 5 and ends in 9, double i is the
    	//new output of our new array index list 
    	protected static void func(double x [], int start, int end, double i) {
    		//we loop through the array to copy in the value 2.3
    		for(int y=start-1; y<end; y++)
    		//connect the whole old array with our new "array"
    			x[y]=i;
    	}
    }
    That what its easier to read.

  4. #3
    Join Date
    May 2008
    Location
    Hell
    Posts
    3,852
    Blog Entries
    4
    Rep Power
    49

    Talking Re: Abstract method(SIMPLE VERSION)

    Quote Originally Posted by John View Post
    My only recommendation I have is make your comments easier to read (so they dont scroll off the page).

    Code:
    public class abstractmethod {
    	public static void main(String [] arg) {
    		
    		//We make an array with a index list 
    		//containing with the numbers of 0-9
    		double d[] = new double[10];
    		
    		//Our mission, d(the array) in index 5 and 9
    		//enter in the value 2.3(BUT, this will not work
    		//out of the box, yet !) 
    		func(d,5,9,2.3);
    
    		//Looping through the array
    		for(double q : d)
                   ////Printing the array's index numbers value one by one.
    			System.out.println(q);
    		
    	}
    
    	//our abstract method. We start with using the function 
    	//int start is connected to 5 and ends in 9, double i is the
    	//new output of our new array index list 
    	protected static void func(double x [], int start, int end, double i) {
    		//we loop through the array to copy in the value 2.3
    		for(int y=start-1; y<end; y++)
    		//connect the whole old array with our new "array"
    			x[y]=i;
    	}
    }
    That what its easier to read.
    Oh thanks sorry about that

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Java abstract class - simple view of it.
    By Turk4n in forum Classes and Code Snippets
    Replies: 0
    Last Post: 01-06-2010, 10:15 AM
  2. JComboBox - Simple Version !
    By Turk4n in forum Java Tutorials
    Replies: 9
    Last Post: 08-07-2009, 10:22 PM
  3. CodeCall's First Applet - Simple Version !
    By Turk4n in forum Java Tutorials
    Replies: 13
    Last Post: 01-15-2009, 01:09 AM
  4. ArrayList - Simple version !
    By Turk4n in forum Java Tutorials
    Replies: 14
    Last Post: 01-09-2009, 04:57 AM
  5. Tutorial paint dots(simple version)
    By Turk4n in forum Java Tutorials
    Replies: 6
    Last Post: 06-25-2008, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

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