I have defined for my project a functional interface called And in my field object, I have this: It works fine, and it looks like javascript, but still I can not give it the purpose of my attention. But consider that I want to develop this method: This will attach some specific code of each element of the matrix (in this case, function implementation). In this way, I can use my properties. But every object of the matrix is a square. How can I reach it? I can pass it to the function, make a small change in But still, I will be stuck in the Yes, you need to make it normal The simplest case: < / P> Each of the public zeros (Tasks & Square; so that you only get the function . Its only way, call , like this:
public interface function {public zero call (); }
public square field {private class [] [] matrix; // Square is suitable for public areas (int rows, int colals) {matrix = new square [rows] [column]; For (int i = 0; i & lt; rows; i ++) {for (int j = 0; j & lt; cols; j ++) {this.matrix = new square (i * square.NORMAL_WIDTH, J * square. NORMAL_HEIGHT); }}}}
public zeros each (function function) {int rows = matrix.length; {Int cols = matrix [i] for (int i = 0; i & lt; rows; i ++). Length; For (int j = 0; j & lt; cols; j ++) {f.call (); }}}
// parameter. Public Interface Function {Public Zero Call (Square Square); } Each of the public zeros (function f) {int rows = matrix.length; {Int cols = matrix [i] for (int i = 0; i & lt; rows; i ++). Length; For (int j = 0; j and lt; cols; j ++) {ficol (matrix [i] [j]); }}} class type. I can use the common type, maybe?
Public interface function & lt; T & gt; {Public Zero Call (T-AGR); } Better practice each () is to declare as follows: {0}}
Each of the public zeros (function & lt; super squire & gt; f) {...} function & Lt; Square & gt; , but its any supertype's function , such as
function & lt; Object & gt; Print = new function & lt; Object & gt; () {Public Zero Calls (Object Arg) {System.out.println (arg); }}
No comments:
Post a Comment