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

What is Inbuilt Functions in Java?

$$/$$

In the previous sessions, you created some functions for specific tasks. You have also been using some inbuilt functions throughout this course. So, let’s learn how to use some of the internal libraries in Java, that contain functions that could make your life easy.

 

Note: You can download the codes used in the video from below :

$$/$$

In this lecture, you saw some of the commonly used internal functions. Internal functions can really help you save time. You should use them as often as you can.

 

Video Transcript: 

 

Hi. You created your own functions in the previous lectures, but Java also contains inbuilt libraries and functions that you can use in the future to ease your efforts. Let's begin with the function you've probably seen and implemented multiple times already system out print. This is actually a Java function that prints whatever value is passed into it. You also use the function String Length, which return the length of a string. Unlike what it seems, there are several lines of code executed before they give the result. The print statement is an inbuilt function and so is length. You already used multiple such functions without going into the detail of how they are executed. Let's learn how to use some of the internal libraries that contain functions that could make your life easy. You use the basic mathematical operators such as addition, subtraction, multiplication and division. You also used a statement Math Square root to find the square root of a number. There are other functions in the Math library as well. Let's look at the Math internal library.

 

As you can see, this is the documentation provided by Oracle for a Math library. This is an inbuilt library and you can find the entire documentation of it on the Oracle documentation site. So let's look at the absolute function in our Math library. The absolute function helps us find the absolute value of a number without its positive or negative sign. Next, we will look at the max function which helps us in finding the greater value between the two numbers provided. Over here, I want to find out the absolute value of minus nine. And I can do this by using the Math Library and the apps function provided by it. We then print out the absolute value. Next, let's say I want to find out the maximum value between 89 and 64. I would simply call the max function provided by the Math library that we just saw. Let me run this code.

 

 As you can see, the absolute value of minus nine is nine and this is what we see here. And the maximum value between 89 and 64 is 89, as you can see here. Let's now look at the documentation for the string library. There are multiple functions here. If you look at it, we have an equals method that helps us in comparing two strings if they are equal or not. Similarly, we have equals ignore case, which helps us in ignoring the cases when comparing two strings. Next, we have your length function that helps us find the length of the string. You also have your concat function that helps you concatenate two strings. That is, it helps you add two different strings into one string. Let's use some of these in our code over here, I have declared a string one variable which holds hero in it. Next, I want to find out the length of the string. So I'm simply going to use the string length function provided by my string library. I'm going to declare two compare variables. In the first compare variable, I'm going to check if string one is equal to Hero. Any idea what the result of this would be? It should return as false since we are comparing a hero that has small H with a string hero that has capital H. So let's say you want to ignore the case difference between hero which has capital H and hero that has knowledge. You can simply use dot equals ignore case and this should return you true. Next, you have string two that could be your first name, string three, your second name and let's say I want my string four to be a concatenation of first name and second name so I just call the Concate function and write string three string two dot Concate string three would just combine first name and second name. Let me run this code so you have a better idea.

 

As you can see, the first system, the first print statement, throws us false because we are comparing capital edge hero with small letter H hero. Next, the compare two returns true value because we have explicitly ignored the cases in here. Third, we simply combine string two and string three that is first name and second name as you can see in the last statement.

 

Video Recap:

 

  • Java has inbuilt libraries and functions that can be used to simplify coding efforts

  • Examples of inbuilt functions include System.out.print and String Length

  • There are also internal libraries like Math and String with multiple functions

  • Math library includes functions like absolute and max, which can be used to find the absolute value of a number and the greater value between two numbers, respectively

  • String library includes functions like equals, equals ignore case, length, and concat, which can be used to compare strings, find the length of a string, and concatenate strings

  • Examples of how to use these functions are demonstrated in the video

  • Java documentation site provides detailed information about these inbuilt libraries and functions.

$$/$$

There is an internal library called arrays, which can perform multiple operations on arrays.

https://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html

 

Find the function that can sort an array, and use it to sort the array given in the question.

(Hint:  Use the internal library sort() to sort a given array. For e.g.,  sort(long[] a) sorts the specified array in ascending numerical order.)