-2

I saw many of article , clearly saying that pointer is applicable for jvm not for programming level and also if define null to object level(reference),and performing any operation on that object it will give NullPointerException. if any suggestion please

public class ItCaseContrext_Group
{

    @Test(expectedExceptions=NullPointerException.class)
    @DataProvider(name="td")

    public Object[][] datamethod(ITestContext context) throws Exception 
    {
        Object[][] data=null;

        for(String g:context.getIncludedGroups())
        {
            System.out.println(" i am in for loop");
            if(g.equalsIgnoreCase("A")) 
            {
            data= new Object[][] 
                        {
                    {"10","20"},
                    {"30","40"}
                        };
                 System.out.println(" A");
                        break;
            }
            else if(g.equalsIgnoreCase("B"))
            {
                System.out.println(" B");
                data = new Object[][] 
                        {
                    {"abdul","kalam"},
                    {"Steve","jobs"}
                        };
                        break;
            }
        }
        return(data);
    }
    @Test(dataProvider="td",groups= {"A"})
    public void m1(String a, String b)
    {
        System.out.println(a+" "+ b);

    }




    @Test(dataProvider="td",groups= {"B"})
    public void m2(String a, String b)
    { 
    System.out.println(a+" "+ b);
    }


}
RamPrakash
  • 1,687
  • 3
  • 20
  • 25
Raja
  • 1
  • 1
  • 1
    Does this answer your question? [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – AndiCover Jan 31 '20 at 14:09

1 Answers1

0

It's not quite clear what you're asking.

Java doesn't have pointers like C, but an object still exists in memory. If you name an object but don't create it, and then try to use that object, then the NullPointerException error will occur because the object didn't exist yet.

arowell
  • 2,271
  • 2
  • 15
  • 19