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
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 AnalyticsMS 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 Administration | STEMMS 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 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 MediaMSc Sustainable Tourism and Event ManagementMSc in Circular Economy and Sustainable InnovationMSc in Impact Finance and Fintech ManagementMS Computer ScienceMS in Applied StatisticsMaster 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 ManagementMBA in Strategic Data Driven ManagementMSc Digital MarketingMBA Business and MarketingMaster of Business AdministrationMSc in Sustainable Global Supply Chain ManagementMSc 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 AdministrationMaster of Business AdministrationMSc in International FinanceMSc in International Management and Global LeadershipMaster of Business AdministrationBachelor of BusinessMaster of Business Administration 60 ECTSMaster of Business Administration 90 ECTSMaster of Business Administration 90 ECTSBachelor of Business AnalyticsBachelor of Information TechnologyMaster of Business AdministrationMBA Business AnalyticsMSc in Marketing Analytics and Data IntelligenceMS Biotechnology Management and EntrepreneurshipMSc in Luxury and Fashion ManagementMaster of Business Administration (90 ECTS)Bachelor of Business Administration (180 ECTS)B.Sc. Computer Science (180 ECTS) MSc in International Corporate Finance MSc in Sustainable Luxury and Creative IndustriesMSc Digital Marketing
For College Students

Introduction to Data Types in Java - I

$$/$$

Now that you learnt that a variable can store a value of a particular type, in this section, you will learn what the various types are.

 

You have already used the int keyword to store integers. In the following video, you will learn more about the int data type.

$$/$$

Video Transcript

 

So you remember that for declaring or updating any new variables, first we had to tell the computer, we had to tell the program beforehand what kind of information we are going to store inside those variables. So you remember statements such as these int x equals to say three. So now here I told you that there is this keyword int which is used in Java. So this keyword int stands for what we call as integer. So whenever we are telling the program that this is the kind of information you're going to store in the variable, we also have to specify things like int or things like string. So these are what we call as the different data types in Java. So whenever I'm talking about data type, it basically signifies what kind of information I'm going to store. If my data type is an integer, then I denote it by int. Or if my data type is say, something else, a character, then I denote it by some other keyword. So now we are going to take a look at the different data types in Java. So one of the most commonly used and one of the most fundamental data types in Java is the integer data type. This is denoted by the keyword int. I say int x equals to three. And you remember why I was actually telling the computer beforehand that I'm going to use int? Well, so that the program knows how much space it has to allocate for storing this particular variable. So going on another level, we say that I say int x equals to three. So the program assigns a certain amount of computer memory for storing this variable. Specifically, Integer data type is made up of 32 bits. So you can imagine bits as being the smallest unit of storing information inside a computer. So this is a single bit. So whenever I am declaring a new int, it will consist of 32 such bit values or 32 such small boxes. The bit is the smallest unit of storing any information in the computer and a bit can only contain zero or one. So now Integer has 32 bits inside it. So even when I have to store a value, say three inside it, it will allocate 32 small boxes or 32 bits for storing this particular number. So this is how you can store any given number into the Integer data type. And till what values can I store inside int? That is, what is the range of this int? Well, you can store any number between minus two to the power 31 till two to the power 31 minus one. So how is this range coming about? Well, you can read more about this range in the link which is given on this particular particular section.

 

Video Recap

 

 

  • In Java, when declaring or updating variables, you must specify the type of information that will be stored inside.

  • Data types in Java are used to signify the kind of information being stored, such as int for integers and string for text.

  • The int data type is one of the most commonly used and fundamental data types in Java.

  • The keyword "int" is used to denote the integer data type and is followed by the variable name and value, such as int x = 3.

  • The computer assigns a certain amount of memory to store the variable, with the int data type consisting of 32 bits or 32 small boxes.

  • The smallest unit of storing information in a computer is a bit, which can only contain a value of zero or one.

  • The range of the int data type is from -2 to the power of 31 to 2 to the power of 31 minus one.

  • More information about the range of the int data type can be found in the provided link.

 

The integer data type can be used to store integers between - to -1.

If you wish to understand how this range is calculated, you can go here.

 

Since the int data type can only store numbers in a particular range, what will you do if you wish to store a larger number? Or if you want to store a really small number, would you want the computer to allocate a large chunk of memory which int occupies? Clearly, for storing larger numbers and optimal memory usage, we need different “containers” or data types.

 

In the following video, you will learn about two more data types which can store integers within different ranges.

$$/$$

Through the video above, you learned about two more data types:

  1. long- This can store integer data within the range - to -1. (Note that “long” and “Long” are two different data types in Java. You will understand more about the difference much later in this course.)

  2. short- This can store integer data within the range - to -1.

 

Till now, you have learned about data types which can only store whole numbers and integers. There certainly has to be a way to store other rational numbers.

 

In the following video, you will learn about data types called float and double which can store decimal values.

$$/$$

You learned about the following two data types:

  1. float: This data type can store numbers with 7 digits after the decimal.

  2. double: This data type can store numbers with 16 digits after the decimal

 

Note: Remember to append “f” to the number before storing it in a float variable to make sure that it is not interpreted as a double. 

 

Till now you have only seen how numbers can be stored in variables and data types to store different kinds of numbers. In the next segment, you will learn how to store some other kind of data too like binary values and characters.