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

What Are Up Next-Functions in Java

$$/$$

In the upcoming session, you will learn about something called functions.

Let us try to understand what functions are and how will they help us.

$$/$$

Video Transcript

 

In the next session you're going to take a look at a very interesting concept in Java which we call as functions. So basically, going by the name functions itself, a function does nothing but perform some certain set of actions as soon as you call that function. So why would you need to use functions in the first place? Now imagine that we wrote a code like this. So this code basically prints the list of all the even numbers between zero till 100. Now, if you wish to reuse this code somewhere else in the program, well, how would you do that? Given our current knowledge, we have no other way but to write this entire piece of code again. Suppose I write this piece of code here and it prints down the list of all even numbers. Now if I again need to print the list of even numbers somewhere else in the program, then I would need to write all these four lines again. Is there a clever and more efficient way to do the same job? Well, here is where functions come into play. So basically functions are like this black box and inside the black box you have some certain actions which are getting performed. You call this function, you give it some name function name. And when you want these several actions to get executed, you simply call this function. So basically, if I want these three four statements or these three four actions to get executed whenever I want, I can enclose this entire thing within the box of what I call as the function. I have to give a name to this function. Suppose this function is called as Print Even. So in this case I simply need to write print even when whenever I want this entire box of actions to execute. So function is basically nothing, but it is a bigger box containing a list of actions that function or that box has a name. And whenever you want those several actions to get executed you simply call that function or you write that function in your program.

 

Video Recap

 

  • Functions in Java perform a certain set of actions when called

  • Using functions allows for reusability of code

  • Functions are like a black box containing actions that can be executed by calling the function

  • Giving a name to the function allows for easy execution of the actions within the box

  • Functions are a more efficient way of executing repeated actions in a program.

 

You learned that a peice of code to be re-used multiple times in a program can be written as something called a "function" and can be then re-used multiple times.

Consider you have a browser window open, whenever you want to open a new tab you would just click on a button without worrying how a new tab opens.

Functions in Java provide you similar facility to do tasks without worrying about their implementation. You can also write your own functions in Java.

 

Let us now take a look at some useful functions in Java.

$$/$$

You learned about the length() and charAt() functions in Java which tell you the length of the string and give you a character at a particular index respectively.

Let us take a look at another interesting function in Java.

$$/$$

You learned about the length() function which will give you the length of an array.

Java provides you with multiple such functions which make your life easier. Also, you can write your own functions.

In the next session, you will learn more about functions and how they help you in writing better computer programs.