title: How can I create a method without parameters in java?
body: <p>I've been trying to write some code in java and I have some lines that I write in a lot of places(exactly the same). I want to replace those lines everywhere with a method. Is that possible ? </p>
  
  <p>For example </p>
  
  <pre><code>public fill()
  {       x=x+1;
          if( x == sizeX){
              y=y-1;
              x=0;
          }
  }
  </code></pre>
  
  <p>Those variables x,y,size are defined outside the method. I also tried with public void , void and a lot of other combinations that I could find. Is it possible what I am trying to do in java ?</p>