0% found this document useful (0 votes)
3 views

What Are the Functions

The document explains the concept of functions in programming, distinguishing between user-defined functions and standard library functions. It details the syntax for defining functions and provides examples of built-in functions, particularly string methods like concat() and equals(). The document is authored by Vijay Laul.

Uploaded by

Pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

What Are the Functions

The document explains the concept of functions in programming, distinguishing between user-defined functions and standard library functions. It details the syntax for defining functions and provides examples of built-in functions, particularly string methods like concat() and equals(). The document is authored by Vijay Laul.

Uploaded by

Pratik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FUNCTION

 User defined functions

 Inbuilt functions

Created by

Vijay Laul
What are the Functions?

• Functions are a set of instructions that can perform a specific task.

• Functions sometimes take some arguments and return some value after
completing the task.

There are two types of functions:

1. Standard Library functions

2. User defined functions


 Standard Library functions :-

• Some functions are predefined. They are readily available to do different tasks. Some pre-defined
functions are print(), println(), sqrt() etc.

 User Defined functions :-


• User-defined functions are made by programmers. We can define some function to do some
important task.

• Basic syntax of a function definition is:

return_type functionName (argument_list){

//statements

}
PROGRAM :-
package functons;

public class preDefined {

//user defined function. <return type> function_name(<argument_list>)

public static int add(int a, int b) { //function add takes two integer input and return
another integer value

int sum; //sum is local variable of the function add

sum = a + b;

return sum; //return the result as integer data

}
 What are inbuilt functions?

A built-in function is a function that is already available in a


programming language, application, or another tool that can be accessed
by end users.


Categories of Built-in Methods:-

i) String Methods

ii) Number Methods

iii) Character Methods

iv) Array Methods etc…


String Method

• concat() Method :-
(It concatenates two strings /Joins two strings)

package Demo;
public class inbulitFunction {
public static void main (String [] args )
{
String str1 = “Maharastra”;
String str2 = “Pune”;
System.out.println(str1.concat(str2)); // MaharastraPune
}}
 Equals() Method :-
public static void main (String [] args )
{
String str1 = “Maharastra”;
String str2 = “Pune”;
System.out.println(str1.equals(str2)); // false
}
Thank You

You might also like