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 AdministrationMS in Information Technology and Administrative Management MS in Computer Science Master of Business Administration Master of Business Administration-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 ScienceMBA 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 MarketingMSc 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 MarketingMSc 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 FinanceMaster of Business AdministrationBachelor of BusinessBachelor 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 MarketingMSc Global Supply Chain Management (PGMP)MSc Marketing (PGMP)MSc Corporate Finance (PGMP)MSc Data Analytics for Business (PGMP)MS Business AnalyticsMaster of Business AdministrationMS Quantitative FinanceMS Fintech ManagementMS Business Analytics PGMPState University of New York Bachelors Program - STEM MSc Business Intelligence and Data Science (PGMP)MSc International Logistics and Supply Chain Management ( PGMP)MSc International Management (PGMP)MSc Psychology & Management (PGMP)State University of New York Bachelor's Year 1 ProgramMaster of Health Services AdministrationM.A Digital Marketing (PGMP)MS in Technology Leadership and Project ManagementMaster of Health Services Administration and Master of Business Administration (Dual Degree)MSc in Supply Chain ManagementMSc in Hospitality ManagementMaster of Business Administration 60 ECTS UAMMaster of Business Administration 90 ECTSMaster of Computer Science 90 ECTSM.Engg Industrial Engineering 90 ECTSM.A in Management 90 ECTSMS in Data AnalyticsMS in Artificial IntelligenceMaster of Business AdministrationMA International Business & LeadershipMaster of Business Administration 90 ECTSMA International Hospitality Management 120 ECTS
For College Students

$$/$$

As you already learned, “char” data type is used to store single characters like ‘a’, ‘$’ or ‘1’.

Let us take a look again at what the char data type can and cannot store.

$$/$$

As you learned, the char data type can only store a single character and this calls for a way to be able to store sentences or a set of characters.

String data type helps you do exactly this.

$$/$$

In the previous video, you learnt how to initialise and declare a string variable by using the keyword ‘String’. All the values of this data type should be enclosed within double quotes.

Also, you learnt about string concatenation, which is the combining of two or more strings to create one single string. Here, empty double quotes or spaces after quotes are used to ensure proper spacing in the  final string. Eg. The concatenation of ‘Ankit’ and ‘Garg’ to print ‘Ankit Garg’ can done by writing “Ankit” + “ ” + “Garg”.

 

Let us now try to run the code you learned about.

You can download the following java file which will be very useful to you while watching the video. Right click on the java file and open it with Intellij. Please be careful with the name of the java file. The name of the java file should exactly be same as the class name inside it for the code to run. So make changes accordingly.

$$/$$

Now you know how to store numbers, characters as well as long sentences in Java. In the next segment, you will learn how to store multiple numbers, characters or sentences together in something called an ‘Array’.

$$/$$

Video Transcript

 

Now let us take a look at another data type here in Java called Strings and Characters. So basically you would have learned that Characters is another data type which is used to store single characters in Java. By those single characters I mean alphabets or digits or any special characters as well. So basically for bearing a new character, I can say that care x equals two. Then I can assign a value such as A to it. Note that whenever you are assigning a particular value inside a care variable, you always need to enclose it within single quotes. So you cannot really use double quotes for this. And you must always be careful to use single quotes for declaring any care value. So now let us see whether this is a valid statement. Care y equals to five. So you will see that in this case, this five will not be treated as an integer but will be treated as the character five. So yes, this is a valid statement and also this is a valid statement. Now can you tell me whether this is a valid statement?

 

Well, we saw that a character data type can only contain a single character inside it. So statements like these are incorrect and the program will throw an error if you try to declare any statement like this. Similarly, if you declare something like this care c equals to say true then also it is going to be an invalid statement.

 

Video Recap

 

  • Java has two data types for storing Strings and Characters.
  • Characters can store single characters such as alphabets, digits, and special characters.

  • To assign a value to a character variable, it must be enclosed in single quotes, not double quotes.

  • The value assigned to a character variable will be treated as a character, even if it's a number.

  • A character data type can only contain a single character, so statements like "care c = 'hello'" are incorrect and will cause an error.

  • Assigning a Boolean value to a character variable is also invalid.