Data providers in testng

We can provide a data provider to any of our tests in testng like this

@Test(dataProvider="registerData")
public void TestData(String name,String email,String password,String city){
System.out.println(name+"------" +email+"-------"+password+"---"+city); }

If data provider is from a different file ,we give a class name as well

@Test(dataProviderClass=RegTest.class,dataProvider ="registerData")

And we can define a data provider like this

@DataProvider
//We make a function that returns a two dimensional object array
public Object[][] registerData(){
Object[][] data = new Object[3][4];
//Then we make an two dimensional object array
//rows mean the no of times we want to run the test
//Columns mean the actual data we will pass in the test
return data;
}