- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between Java references and pointers in other languages?
Reference datatypes in java are those which contains reference/address of dynamically created objects. These are not predefined like primitive data types.
Following are the reference types in Java.
class types − This reference type points to an object of a class.
array types − This reference type points to an array.
interface types − This reference type points to an object of a class which implements an interface.
Once we create a variable of these types (i.e. when we create an array or object, class or interface).
These variables only store the address of these values.
Default value of any reference variable is null.
A reference variable can be used to refer any object of the declared type or any compatible type.
Animal animal = new Animal("giraffe");
A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. The general form of a pointer variable declaration is −
int *ip; /* pointer to an integer */ double *dp; /* pointer to a double */ float *fp; /* pointer to a float */ char *ch /* pointer to a character */
- Related Articles
- What is the difference between Imperative languages and Functional languages in compiler design?
- C/C++ Pointers vs Java references\n
- Pointers vs References in C++
- What is the difference between Procedural and Non-Procedural Languages in compiler design?
- Difference between Array and Pointers in C
- When to use references vs. pointers in C/C++
- What is the difference between Java and Core Java?
- What is the difference between Java and Java EE
- What is the difference between humans and other species on earth?
- What is the difference between /* */ and /** */ comments in Java?
- What is the difference between >> and >>> operators in Java?
- What are the constructor references in Java?
- What are the method references in Java?
- Why is Python slower than other languages?