Calling methods in java (Selenium/Apache-POI included)
<p>I have created a class'ReadURL' which fetches the URLs present in an excel.</p>

<pre><code>public class ReadURL
{
static String val;
public String readExcel(String path,String tab,int rowNum,int cellNum) throws Exception
{
      FileInputStream fis = new FileInputStream(path);
      Workbook wb = WorkbookFactory.create(fis);
      Sheet sh = wb.getSheet(tab);    
      Row row = sh.getRow(rowNum);
      String val = row.getCell(cellNum).getStringCellValue();
      return val; 
}
}
</code></pre>

<p>I am calling the above method from another class 'DeadLinks', which has main method, by declaring values.</p>

<pre><code>public class DeadLinks 
{
public static void main(String[] args) throws Exception
{
    String addr = "C:/Users/sjois/Documents/Automation/TestURLs-Dev.xlsx";
    String sht = "USpages";
    int r = 2;
    int c = 0;
    ReadURL url = new ReadURL();
    url.readExcel(addr, sht, r, c);
    System.out.println(ReadURL.val);
}
}
</code></pre>

<p>When I execute 'ReadURL' class with main method and by hard coding the values, things work fine. However, when I try to call the function from another function, this always return 'Null'. I'm not getting any error during compilation or runtime.
Where am I going wrong?</p>