Back To Java User Defined Methods Index
//program to create a function that display hello world for a specified number of times class displayntimes { public void display(int n) { int i; for(i=1;i<=n;i++) { System.out.println("hello world"); } } } public class displayhellonotimes { public static void main(String[] args) { displayntimes ob=new displayntimes(); ob.display(10); } }