---
title: "What is the difference between declaring a variable and defining a variable?"  
description: "What is the difference between declaring a variable and defining a variable?"  
author: "Anonymous User"  
published: 2015-07-24  
updated: 2020-09-23  
canonical: https://www.mindstick.com/interview/2730/what-is-the-difference-between-declaring-a-variable-and-defining-a-variable  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What is the difference between declaring a variable and defining a variable?

In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.\
e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.

## Answers

### Answer by Anonymous User

In declaration we just mention the type of the variable and it's name. We do not initialize it. But defining means declaration + initialization.\
e.g String s; is just a declaration while String s = new String ("abcd"); Or String s = "abcd"; are both definitions.


---

Original Source: https://www.mindstick.com/interview/2730/what-is-the-difference-between-declaring-a-variable-and-defining-a-variable

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
