Skip to player
Skip to main content
Search
Connect
Watch fullscreen
Like
Bookmark
Share
More
Add to Playlist
Report
(Sigma batch 2025) syntax function code by shradha didi
Prateek Prajapati
Follow
4 months ago
Sigma batch
Category
📚
Learning
Transcript
Display full video transcript
00:00
Now, what is the syntax of code in the code?
00:03
The syntax is that, first of all, we write the return type.
00:07
Does this function return value?
00:09
We can imagine a Java function as a button.
00:13
This button gives us some input and gives us some output.
00:18
If we press the button on the remote TV,
00:21
what is the input?
00:22
It is our thumb movement or finger movement,
00:25
which we press the button.
00:27
What is the output?
00:28
If it is a mute button, the TV will be muted.
00:31
If it is a power-off button, the TV will be closed.
00:36
This is our output.
00:38
In the code, there is such a unit, such a block,
00:42
which gives us some input and output.
00:45
The input is two numbers A and B,
00:48
and the output is the sum of those numbers.
00:50
The input is a number N,
00:53
and the output is the sum of 1 to N.
00:56
We can define any input and output.
01:04
The logic of the function,
01:06
the actual code,
01:08
which will convert the input into the output,
01:10
we have to write it once again.
01:12
Then we can reuse it once again,
01:14
because it is a reusable portion.
01:16
If we go back to the syntax,
01:18
we have to write the return type in the syntax.
01:22
The return type is the output type.
01:24
The output is the last function.
01:26
The output will calculate the actual value.
01:28
What is the type?
01:30
Then we write the name function.
01:32
Then we write the parentheses.
01:34
Then we write the curly braces.
01:36
Then we call the body.
01:38
Then we call the body.
01:40
Then we write the return statement.
01:42
Before we implement the syntax,
01:44
let's understand a little logic.
01:46
This is our basic Java boilerplate code.
01:48
We have a class with Java basics.
01:51
We already have a function.
01:54
We always write it.
01:56
This function is the main function.
01:58
We analyze it.
02:00
The main function is void.
02:02
It is the return type.
02:03
It means void.
02:05
We will add int, float, string, byte, short.
02:11
But void is a valid return type in Java.
02:15
It means void.
02:16
This function does not return anything.
02:19
It is void value.
02:21
We write void.
02:23
Because the main function does not return anything,
02:25
we write void in Java.
02:28
This function is the main.
02:30
Coincidentally, the main is our reserved keyword.
02:33
It means in our Java dictionary it is saved.
02:36
We cannot write any other name.
02:38
In Java we can't write any other name.
02:40
And within this,
02:41
what it has taken the input,
02:42
it is a string, arguments name.
02:45
Args.
02:46
Which is an array.
02:47
What are the array?
02:48
Why are these brackets?
02:50
Why are these brackets?
02:51
We will read this in the array section.
02:53
But now, let's assume and assume
02:56
that this is the main function of the input.
02:59
This is the main function of the output.
03:01
And this is the public static.
03:03
Basically, we call access modifier.
03:05
Which we will read in detail.
03:07
In Java, we have to tell access modifier.
03:11
But what is the access modifier?
03:13
Why is it public?
03:14
Why is it static?
03:15
Why is it private?
03:16
Why is it protected?
03:17
Why is it protected?
03:18
So, we are reading the object oriented programming chapter.
03:21
We are covered within it.
03:23
We have to assume that in public static,
03:25
we must always use public static.
03:26
Then it is my return type.
03:27
Then it is my name.
03:29
There will be input within it.
03:31
And here,
03:32
we have the body.
03:33
The body is a function that allows me to perform the work.
03:37
Even now, we will do the main function.
03:39
We are all in the main function
03:42
Like if I want to print hello world
03:45
I can say that my main function
03:48
I will print hello world
03:51
I can save and run
03:52
I will also have output
03:54
I always want to do my main work
03:57
But I need to print hello world
04:00
Like I have printed hello world
04:03
I have printed hello world
04:06
Then I have performed work 1
04:10
Then I need to print hello world
04:13
Then I need to perform work 2
04:15
Then I need to print hello world
04:18
There are functions that we need to do
04:21
We need to do code
04:24
We need to copy and paste the same logic
04:28
If I have written a code
04:30
I need to print hello world
04:32
If I need to print hello world
04:36
Then I need to copy and paste it
04:39
Then we need to create a reusable part
04:42
For that we can write a function
04:45
What is our first function?
04:47
To print hello world
04:49
What will we do?
04:50
The main function exists
04:52
What will we do?
04:53
We will create a new function
04:54
Which we will create itself
04:56
The start of the new function
04:58
We need to write public static
05:00
These are access modifiers
05:01
What will happen?
05:02
We will talk about it
05:03
After that we will write
05:04
The return type
05:05
Now we are trying to create a function
05:06
Now we are trying to create a function
05:08
Which is just to print hello world
05:10
So does it need to be input?
05:12
No
05:13
It doesn't need to be input
05:14
Does it need to be output?
05:16
It needs to be output
05:17
Once it has printed hello world
05:19
Then it doesn't need to be value
05:20
So we need to write value
05:22
This function of return type
05:23
We will write void
05:25
Because this function
05:26
It will not return any function
05:28
It will not return any function
05:29
The return type is void
05:30
Now I can give it to my function
05:32
But I will give it to my function
05:35
Which will relate to its work
05:37
Because in this function
05:39
I have to print hello world
05:40
So I will give it a name
05:41
Print hello world
05:44
I have given it
05:46
Print hello world
05:47
I have given it
05:48
And then I have put parentheses
05:50
I have put parentheses
05:51
These braces
05:52
Then I have put curly braces
05:54
And put curly braces
05:56
And this curly brace
05:57
This is the code
05:59
This is my block of code
06:01
Which forms my function
06:03
What is my function
06:04
What is my function?
06:05
My function is
06:06
Print hello world
06:09
So I have written a whole function
06:12
How did I write this function?
06:13
First I wrote public static
06:15
Then I wrote return type
06:16
Void
06:17
Then I wrote its name
06:19
Print hello world
06:21
Then I wrote parenthesis
06:22
Then I wrote curly braces
06:23
Then I wrote curly braces
06:24
The code of the function
06:25
We have to write these curly braces
06:27
And what is the action
06:28
In this function
06:29
What is the action
06:30
The action is performed
06:31
In the hello world
06:32
Now I have written this function
06:34
I have written this function
06:35
But if I simply save this code
06:37
And run it
06:38
So my code
06:40
My program is finished
06:41
That means
06:42
It has not been executed
06:43
It has not been executed
06:44
In my Java code
06:45
It has been executed
06:46
It has always been
06:47
Main function
06:48
So what happened?
06:49
Main function
06:50
In the main function
06:51
But because the main function
06:52
is empty
06:53
So this print
06:54
Hello world
06:55
We can't reach this
06:56
If I have to reach this code
06:57
To reach this code
06:58
What should I do?
07:00
What should I do?
07:01
I have to call this function
07:03
I have to call this function
07:04
That means
07:05
Come and perform your work
07:06
So
07:07
For this function
07:08
Call it
07:09
We write its name
07:10
Like this function
07:11
It is called print
07:12
Hello world
07:13
Then we put parentheses
07:15
So the name of the function
07:16
We put parentheses
07:17
Here
07:18
The same parenthesis
07:19
We put in this way
07:20
Then we put our statement terminator
07:22
So what I have to do
07:23
So what I have to do
07:24
I have to call this whole function
07:26
Now
07:27
Where I have to write this whole function
07:29
Where I have to write this whole function
07:30
There will be the whole function
07:31
Execute
07:32
This one time
07:33
Save
07:34
And this one time
07:35
Run
07:36
So what happened
07:37
After running
07:38
Hello world
07:39
How did it print
07:40
How did it print?
07:41
When Java code
07:42
Executed
07:43
So the main function
07:44
Call
07:45
The main function
07:46
Will execute
07:47
So the first thing
07:48
Is to print hello world
07:49
Call
07:50
So what happened
07:51
It has to print hello world
07:52
Call and then
07:53
Hello world
07:54
Printed
07:55
Now print hello world
07:56
It is possible to print hello world
07:58
It is to print hello world
07:59
Three times
08:00
I will write three statements
08:03
And in each statement
08:05
Hello world
08:06
Printed
08:07
But
08:08
When I call the main function
08:09
Then I will write
08:10
Call one time
08:11
Let's do it
08:12
Save
08:13
And run
08:14
Once again
08:15
So I have to print
08:16
Three times
08:17
Hello world
08:18
So when I have to print
08:19
Hello world
08:20
I will write three times
08:21
Hello world
08:22
I will write a single line
08:23
For my function
08:24
Call
08:25
This is
08:26
function
08:27
Call
08:28
We write the name of function
08:30
In the name of function
08:31
And after that
08:32
If we have to pass input
08:33
If we have to pass it
08:34
If we don't pass it
08:35
Then we write the parenthesis
08:36
Now
08:37
In this function
08:38
There is another small thing
08:39
There is no error
08:40
Because the return type is void
08:41
It is
08:42
The return type is void
08:43
The last function
08:44
We have to write return
08:45
After that
08:46
Return
08:47
If the return type is void
08:48
Then we can simply return
08:50
Or remove this return
08:51
No error
08:52
But
08:53
Remember
08:54
Return type
08:55
Int
08:56
So the integer value
08:57
Which the print
08:58
Hello world
08:59
Returns
09:00
It counts
09:01
How many times
09:02
It has to be printed
09:03
So it has to be returned
09:04
Three
09:05
So until the integer value
09:06
It will not return
09:07
From this function
09:08
Then there will be error
09:09
If I will comment out this statement
09:11
Then what will happen
09:12
Here will be a red line
09:14
And the red line will show
09:15
This method must return a result
09:17
Of type int
09:18
This method
09:19
For this function
09:20
It is compulsory
09:21
To return a result
09:23
Which is a type integer
09:24
So this is why
09:26
We don't always write return statement
09:27
When our return type is void
09:30
In which case
09:31
Our return type is void
09:33
Or we can simply write return
09:35
Or not
09:36
We can completely remove this statement
09:38
Now a special thing
09:39
This chapter
09:40
It is not only functions
09:41
This chapter
09:42
It is functions
09:43
And methods
09:44
What are the methods
09:45
Which functions
09:46
We write classes
09:47
They are methods
09:49
So functions
09:51
And methods
09:52
Are the same thing
09:53
Now in C++
09:54
We can write functions
09:55
Out of the class
09:56
But as Java
09:57
Designed
09:58
The whole code
09:59
In the class
10:00
That is why
10:01
This function
10:02
Is written in the class
10:03
In Java
10:04
Basics
10:05
That is why
10:06
We will call this function
10:07
Conventionally
10:08
Method
10:09
But if you call this function
10:10
Or method
10:11
It is no practical
10:12
As such
10:13
Usage
10:14
That is the proper term
10:15
You need to know
10:16
That is why
10:17
The functions
10:18
We call methods
10:19
This chapter
10:20
That is the name
10:21
Functions
10:22
Methods
Be the first to comment
Add your comment
Recommended
6:23
|
Up next
(Sigma batch 2025) syntax with parameters by shradha didi
Prateek Prajapati
4 months ago
2:30
(Sigma batch)Introduction to a Function by shradha didi
Prateek Prajapati
4 months ago
1:55
(Sigma batch 2025) parameters v/s arguments by shradha didi
Prateek Prajapati
4 months ago
5:10
(Sigma batch 2025) what happened in memory by shradha didi
Prateek Prajapati
4 months ago
8:15
(Sigma batch 2025) call by values by shradha didi
Prateek Prajapati
4 months ago
3:42
(Sigma batch 2025) product os a&b by shradha didi
Prateek Prajapati
4 months ago
2:02
Sigma FP Concept Movie
xataka
5 years ago
0:11
Sigma rule
Jack Sparrow
2 years ago
1:57
Sigma Girl Expression
Wrestling Arena Anime
3 years ago
0:51
Former Aide Claims She Was Asked to Make a ‘Hit List’ For Trump
Veuer
2 years ago
1:08
Musk’s X Is ‘the Platform With the Largest Ratio of Misinformation or Disinformation’ Amongst All Social Media Platforms
Veuer
2 years ago
4:50
59 companies that are changing the world: From Tesla to Chobani
Fortune
2 years ago
0:46
3 Things to Know About Coco Gauff's Parents
People
2 years ago
1:18
USC vs. Colorado: Can Caleb Williams Earn a New Heisman Moment?
SportsGrid
2 years ago
1:04
Vic Mensa Reveals Celebrity Crush, Biggest Dating Pet Peeve & More on Speed Dating | Billboard News
Billboard
2 years ago
1:09
Hollywood Writers Reach ‘Tentative Agreement’ With Studios After 146 Day Strike
Veuer
2 years ago
1:26
Love is Blind stars admit they're burnt out from social media
Fortune
2 years ago
2:01
NHA Customers in Limbo as Company Faces Potential Merger
SportsGrid
2 years ago
2:55
Vanilla Ice Explains How the 90’s Shaped America
FACTZ
2 years ago
0:36
Amazon’ Prime Video Will Show Commercials Starting Next Year
Veuer
2 years ago
11:13
Pokimane Answers The Web's Most Searched Questions
WIRED
2 years ago
4:16
BREAKING NEWS: Matt Gaetz Tells House Committee: 'I'm Not Going To Vote For A Continuing Resolution'
Forbes Breaking News
2 years ago
1:00
What's Popular on Uber Eats?
Stringr
2 years ago
2:50
MÃ¥neskin Performs "HONEY" at MSG
Rolling Stone
2 years ago
12:13
Matt Rife Hilariously Roasts Your Dating Profiles | Cosmopolitan
Cosmopolitan USA
2 years ago
Be the first to comment