COURSES
MBAData Science & AnalyticsDoctorate Software & Tech AI | ML MarketingManagement
Professional Certificate Programme in HR Management and AnalyticsPost Graduate Certificate in Product ManagementExecutive Post Graduate Program in Healthcare ManagementExecutive PG Programme in Human Resource ManagementMBA in International Finance (integrated with ACCA, UK)Global Master Certificate in Integrated Supply Chain ManagementAdvanced General Management ProgramManagement EssentialsLeadership and Management in New Age BusinessProduct Management Online Certificate ProgramStrategic Human Resources Leadership Cornell Certificate ProgramHuman Resources Management Certificate Program for Indian ExecutivesGlobal Professional Certificate in Effective Leadership and ManagementCSM® Certification TrainingCSPO® Certification TrainingLeading SAFe® 5.1 Training (SAFe® Agilist Certification)SAFe® 5.1 POPM CertificationSAFe® 5.1 Scrum Master Certification (SSM)Implementing SAFe® 5.1 with SPC CertificationSAFe® 5 Release Train Engineer (RTE) CertificationPMP® Certification TrainingPRINCE2® Foundation and Practitioner Certification
Law
Job Linked
Bootcamps
Study Abroad
Master of Business Administration (90 ECTS)Master of Business Administration (60 ECTS)Master in Computer Science (120 ECTS)Master in International Management (120 ECTS)Bachelor of Business Administration (180 ECTS)B.Sc. Computer Science (180 ECTS)MS in Data AnalyticsMS in Project ManagementMS in Information TechnologyMasters Degree in Data Analytics and VisualizationMasters Degree in Artificial IntelligenceMBS in Entrepreneurship and MarketingMSc in Data AnalyticsMS in Data AnalyticsMaster of Science in AccountancyMS in Computer ScienceMaster of Science in Business AnalyticsMaster of Business Administration MS in Data ScienceMS in Information TechnologyMaster of Business AdministrationMS in Applied Data ScienceMaster of Business AdministrationMS in Data AnalyticsM.Sc. Data Science (60 ECTS)Master of Business AdministrationMS in Information Technology and Administrative Management MS in Computer Science Master of Business Administration MBA General Management-90 ECTSMSc International Business ManagementMS Data Science MBA Business Technologies MBA Leading Business Transformation Master of Business Administration MSc Business Intelligence and Data ScienceMS Data Analytics MS in Management Information SystemsMSc International Business and ManagementMS Engineering ManagementMS in Machine Learning EngineeringMS in Engineering ManagementMSc Data EngineeringMSc Artificial Intelligence EngineeringMPS in InformaticsMPS in Applied Machine IntelligenceMS in Project ManagementMPS in AnalyticsMS in Project ManagementMS in Organizational LeadershipMPS in Analytics - NEU CanadaMBA with specializationMPS in Informatics - NEU Canada Master in Business AdministrationMS in Digital Marketing and MediaMS in Project ManagementMaster in Logistics and Supply Chain ManagementMSc Sustainable Tourism and Event ManagementMSc in Circular Economy and Sustainable InnovationMSc in Impact Finance and Fintech ManagementMS Computer ScienceMS in Applied StatisticsMS in Computer Information SystemsMBA in Technology, Innovation and EntrepreneurshipMSc Data Science with Work PlacementMSc Global Business Management with Work Placement MBA with Work PlacementMS in Robotics and Autonomous SystemsMS in Civil EngineeringMS in Internet of ThingsMSc International Logistics and Supply Chain ManagementMBA- Business InformaticsMSc International ManagementMS Computer Science with AIML ConcentrationMBA in Strategic Data Driven ManagementMaster of Business AdministrationMSc Digital MarketingMBA Business and MarketingMaster of Business AdministrationMSc Digital MarketingMSc in Sustainable Luxury and Creative IndustriesMSc in Sustainable Global Supply Chain ManagementMSc in International Corporate FinanceMSc Digital Business Analytics MSc in International HospitalityMSc Luxury and Innovation ManagementMaster of Business Administration-International Business ManagementMS in Computer EngineeringMS in Industrial and Systems EngineeringMSc International Business ManagementMaster in ManagementMSc MarketingMSc Business ManagementMSc Global Supply Chain ManagementMS in Information Systems and Technology with Business Intelligence and Analytics ConcentrationMSc Corporate FinanceMSc Data Analytics for BusinessMaster of Business AdministrationMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSBachelors in International Management
For College Students

Introduction to Variables in Java

$$/$$

The first stepping stone to computer programming is understanding what are variables. Be it in Java or any other programming language you may choose, variables play a very important role in your program. Variables are storage units in your program and facilitate a major chunk of computations you will be doing.

Through the video below, you will understand what variables are and why do we need them.

$$/$$

Video Transcript

 

So till now you have learned how to write simple print statements in Java. But merely printing text or other information is not sufficient. You can do a lot more with computer programs. For example, if you have a list of certain students who enrolled in a certain course and have secured some marks in a particular subject, then you can store that information also and then later on reuse it. So what is the advantage of storing information? Well, computers are basically used for storing and doing a lot of calculations. So do you recall what happened when we wrote a simple print statement? For example, if you wrote a simple print statement to print the name of a student, that information was printed on the console and it got immediately lost. That is, you could no longer use the name of the student anywhere later in the program. But just imagine a scenario where you are writing a big program in which you have to maintain a list of a large number of students with a large number of marks. So if you keep writing print statements for them, there is no point because all that information is not stored anywhere. So if you need to store any kind of information, you obviously need some containers to store that particular information. For example, if there is a student with the name Adam, and if there is another student with the name Lucy, and if you simply print them, then this information gets immediately lost. However, if you store the names of these students in certain containers, then later on you can use their names somewhere later in the program as well. Moreover, you can do a lot more stuff. For example, you can store their marks in a certain subject and later on use those stored containers to make other calculations.

 

So this brings us to one of the most fundamental and basic building blocks in Java programming languages, which we call as the variables. So basically, variables are nothing but simply containers in which you can store these pieces of information. You can imagine them as boxes or containers which will contain the names of these students. They can also contain suppose, marks of these students and a lot more. So we are going to take a look at variables in a little more detail now. So you can imagine Java variables as being a safe house of any information which you want to retrieve. So we say that variables are nothing but containers which can contain some information. For example, I might have these two containers which will store the marks of a certain student. So suppose student Adam has marks 72 in one subject and 85 in another subject. Then I can store this 72 and this 85 into separate containers. So these two separate containers will be called as two separate variables. And why am I doing this? Well, I'm doing this because perhaps later, somewhere in the program, I would need to do some calculations on these variables. Perhaps I would need to calculate what are the total marks he scored. So in that case, I can simply access the marks of Adam which are contained in these two containers and add them.

 

Video Recap

 

  • In Java programming, it's not enough to just print information, you also need to store it for later use.

  • Storing information is important because computers are used for storing and doing calculations.

  • If you only print information, it gets immediately lost and cannot be used later in the program.

  • To store information, you need containers called variables, which can store information such as student names and marks.

  • Variables are like boxes or containers that can hold information and can be accessed later for calculations.

  • Java variables are containers that can store any type of information and can be used to retrieve information later in the program.

You now know what variables are. Variables are simply containers in the computer memory to store the information you want. 

In the following video, you will understand how variables are named and why is this important.

$$/$$

Now you understand that these containers or variables need to be named. But can all types of information be stored in the same type of container? How do we tell the computer about the size of information to be stored in a container?

You will get the answer to these questions through the following video.

$$/$$

Till now, you must be clear on the definition of variables:

Variables are spaces in a computer’s memory that have names associated with them, where you can store data

 

You need to tell the following two things to the computer about a variable:

  1. Name of the variable

  2. The kind of information you would want to store in this variable

The process of doing so is known as variable declaration.

In the next segment, you would learn writing commands in Java to declare variables and also to store values in them.