problem when we declare any structure in c and class in java? help me

in terms of java–
my class is –

class Element{

int value; Element e; }

 public static void main(String[] args){
  Element obj=new Element();  // it  wil assign 0 to obj.value and null to obj.e value by default

 }

but below in c, in similar scenarios, “struct Element obj;” it will give 0 to obj.value by default but what about obj.e=???

my structure in c is as

struct Element1{
int value;
struct Element nextAddress;

};
  
struct Element{
int value;
struct Element *nextAddress;

};


struct Element *head=NULL;
struct Element1 head2=NULL (error why);  

 struct Element head1; //plz exaplain me what will happen when we write this line.. i know 0 will given 
 to value of head1 and 
  what will be assign to  struct nextAddress as by default head1 is  globaly declare in c     //**here 
  we cant intilize this structure to NULL (Why) but in java we can do so**
 // like suppose we have class Element than we can write as *Element e=NULL*;


void main(){
struct Element *p;
    clrscr();
printf("%d",head1.value);//its giving 0
//how to check what is inside head1.nextAddress?? plz help me
//printf("%d",head1.value);


getch();

}

Not sure about java but in c, pointers should be initialized to NULL when declared globally.

Error in the second line is because you are assigning NULL to a non-pointer type variable.

To check the value of next address, since it is a pointer, use %x and refer to it as head->nextAddress

@abdullah768 zero is assignned when variable is declare at global and memory is assigned from data segment and garbage value assigned when variable is local and allocated from stack memory segment i know that dear… why we cant assign NULL to a non-pointer type variable? how to check what value is inside nextAddress as it struct type… we can check int values as printf("d", head1.value); but i want to check printf("??",head1.nextaddress);

Sorry, I hadn’t realized it was declared globally, edited to reflect changes.

You can use %x as pointers are hexadecimals.

NULL can’t be stored in any other data type just like you can’t store c in an int.