Skip to playerSkip to main content
  • 4 months ago
Sigma batch
Transcript
00:00Now, what is the syntax of code in the code?
00:03The syntax is that, first of all, we write the return type.
00:07Does this function return value?
00:09We can imagine a Java function as a button.
00:13This button gives us some input and gives us some output.
00:18If we press the button on the remote TV,
00:21what is the input?
00:22It is our thumb movement or finger movement,
00:25which we press the button.
00:27What is the output?
00:28If it is a mute button, the TV will be muted.
00:31If it is a power-off button, the TV will be closed.
00:36This is our output.
00:38In the code, there is such a unit, such a block,
00:42which gives us some input and output.
00:45The input is two numbers A and B,
00:48and the output is the sum of those numbers.
00:50The input is a number N,
00:53and the output is the sum of 1 to N.
00:56We can define any input and output.
01:04The logic of the function,
01:06the actual code,
01:08which will convert the input into the output,
01:10we have to write it once again.
01:12Then we can reuse it once again,
01:14because it is a reusable portion.
01:16If we go back to the syntax,
01:18we have to write the return type in the syntax.
01:22The return type is the output type.
01:24The output is the last function.
01:26The output will calculate the actual value.
01:28What is the type?
01:30Then we write the name function.
01:32Then we write the parentheses.
01:34Then we write the curly braces.
01:36Then we call the body.
01:38Then we call the body.
01:40Then we write the return statement.
01:42Before we implement the syntax,
01:44let's understand a little logic.
01:46This is our basic Java boilerplate code.
01:48We have a class with Java basics.
01:51We already have a function.
01:54We always write it.
01:56This function is the main function.
01:58We analyze it.
02:00The main function is void.
02:02It is the return type.
02:03It means void.
02:05We will add int, float, string, byte, short.
02:11But void is a valid return type in Java.
02:15It means void.
02:16This function does not return anything.
02:19It is void value.
02:21We write void.
02:23Because the main function does not return anything,
02:25we write void in Java.
02:28This function is the main.
02:30Coincidentally, the main is our reserved keyword.
02:33It means in our Java dictionary it is saved.
02:36We cannot write any other name.
02:38In Java we can't write any other name.
02:40And within this,
02:41what it has taken the input,
02:42it is a string, arguments name.
02:45Args.
02:46Which is an array.
02:47What are the array?
02:48Why are these brackets?
02:50Why are these brackets?
02:51We will read this in the array section.
02:53But now, let's assume and assume
02:56that this is the main function of the input.
02:59This is the main function of the output.
03:01And this is the public static.
03:03Basically, we call access modifier.
03:05Which we will read in detail.
03:07In Java, we have to tell access modifier.
03:11But what is the access modifier?
03:13Why is it public?
03:14Why is it static?
03:15Why is it private?
03:16Why is it protected?
03:17Why is it protected?
03:18So, we are reading the object oriented programming chapter.
03:21We are covered within it.
03:23We have to assume that in public static,
03:25we must always use public static.
03:26Then it is my return type.
03:27Then it is my name.
03:29There will be input within it.
03:31And here,
03:32we have the body.
03:33The body is a function that allows me to perform the work.
03:37Even now, we will do the main function.
03:39We are all in the main function
03:42Like if I want to print hello world
03:45I can say that my main function
03:48I will print hello world
03:51I can save and run
03:52I will also have output
03:54I always want to do my main work
03:57But I need to print hello world
04:00Like I have printed hello world
04:03I have printed hello world
04:06Then I have performed work 1
04:10Then I need to print hello world
04:13Then I need to perform work 2
04:15Then I need to print hello world
04:18There are functions that we need to do
04:21We need to do code
04:24We need to copy and paste the same logic
04:28If I have written a code
04:30I need to print hello world
04:32If I need to print hello world
04:36Then I need to copy and paste it
04:39Then we need to create a reusable part
04:42For that we can write a function
04:45What is our first function?
04:47To print hello world
04:49What will we do?
04:50The main function exists
04:52What will we do?
04:53We will create a new function
04:54Which we will create itself
04:56The start of the new function
04:58We need to write public static
05:00These are access modifiers
05:01What will happen?
05:02We will talk about it
05:03After that we will write
05:04The return type
05:05Now we are trying to create a function
05:06Now we are trying to create a function
05:08Which is just to print hello world
05:10So does it need to be input?
05:12No
05:13It doesn't need to be input
05:14Does it need to be output?
05:16It needs to be output
05:17Once it has printed hello world
05:19Then it doesn't need to be value
05:20So we need to write value
05:22This function of return type
05:23We will write void
05:25Because this function
05:26It will not return any function
05:28It will not return any function
05:29The return type is void
05:30Now I can give it to my function
05:32But I will give it to my function
05:35Which will relate to its work
05:37Because in this function
05:39I have to print hello world
05:40So I will give it a name
05:41Print hello world
05:44I have given it
05:46Print hello world
05:47I have given it
05:48And then I have put parentheses
05:50I have put parentheses
05:51These braces
05:52Then I have put curly braces
05:54And put curly braces
05:56And this curly brace
05:57This is the code
05:59This is my block of code
06:01Which forms my function
06:03What is my function
06:04What is my function?
06:05My function is
06:06Print hello world
06:09So I have written a whole function
06:12How did I write this function?
06:13First I wrote public static
06:15Then I wrote return type
06:16Void
06:17Then I wrote its name
06:19Print hello world
06:21Then I wrote parenthesis
06:22Then I wrote curly braces
06:23Then I wrote curly braces
06:24The code of the function
06:25We have to write these curly braces
06:27And what is the action
06:28In this function
06:29What is the action
06:30The action is performed
06:31In the hello world
06:32Now I have written this function
06:34I have written this function
06:35But if I simply save this code
06:37And run it
06:38So my code
06:40My program is finished
06:41That means
06:42It has not been executed
06:43It has not been executed
06:44In my Java code
06:45It has been executed
06:46It has always been
06:47Main function
06:48So what happened?
06:49Main function
06:50In the main function
06:51But because the main function
06:52is empty
06:53So this print
06:54Hello world
06:55We can't reach this
06:56If I have to reach this code
06:57To reach this code
06:58What should I do?
07:00What should I do?
07:01I have to call this function
07:03I have to call this function
07:04That means
07:05Come and perform your work
07:06So
07:07For this function
07:08Call it
07:09We write its name
07:10Like this function
07:11It is called print
07:12Hello world
07:13Then we put parentheses
07:15So the name of the function
07:16We put parentheses
07:17Here
07:18The same parenthesis
07:19We put in this way
07:20Then we put our statement terminator
07:22So what I have to do
07:23So what I have to do
07:24I have to call this whole function
07:26Now
07:27Where I have to write this whole function
07:29Where I have to write this whole function
07:30There will be the whole function
07:31Execute
07:32This one time
07:33Save
07:34And this one time
07:35Run
07:36So what happened
07:37After running
07:38Hello world
07:39How did it print
07:40How did it print?
07:41When Java code
07:42Executed
07:43So the main function
07:44Call
07:45The main function
07:46Will execute
07:47So the first thing
07:48Is to print hello world
07:49Call
07:50So what happened
07:51It has to print hello world
07:52Call and then
07:53Hello world
07:54Printed
07:55Now print hello world
07:56It is possible to print hello world
07:58It is to print hello world
07:59Three times
08:00I will write three statements
08:03And in each statement
08:05Hello world
08:06Printed
08:07But
08:08When I call the main function
08:09Then I will write
08:10Call one time
08:11Let's do it
08:12Save
08:13And run
08:14Once again
08:15So I have to print
08:16Three times
08:17Hello world
08:18So when I have to print
08:19Hello world
08:20I will write three times
08:21Hello world
08:22I will write a single line
08:23For my function
08:24Call
08:25This is
08:26function
08:27Call
08:28We write the name of function
08:30In the name of function
08:31And after that
08:32If we have to pass input
08:33If we have to pass it
08:34If we don't pass it
08:35Then we write the parenthesis
08:36Now
08:37In this function
08:38There is another small thing
08:39There is no error
08:40Because the return type is void
08:41It is
08:42The return type is void
08:43The last function
08:44We have to write return
08:45After that
08:46Return
08:47If the return type is void
08:48Then we can simply return
08:50Or remove this return
08:51No error
08:52But
08:53Remember
08:54Return type
08:55Int
08:56So the integer value
08:57Which the print
08:58Hello world
08:59Returns
09:00It counts
09:01How many times
09:02It has to be printed
09:03So it has to be returned
09:04Three
09:05So until the integer value
09:06It will not return
09:07From this function
09:08Then there will be error
09:09If I will comment out this statement
09:11Then what will happen
09:12Here will be a red line
09:14And the red line will show
09:15This method must return a result
09:17Of type int
09:18This method
09:19For this function
09:20It is compulsory
09:21To return a result
09:23Which is a type integer
09:24So this is why
09:26We don't always write return statement
09:27When our return type is void
09:30In which case
09:31Our return type is void
09:33Or we can simply write return
09:35Or not
09:36We can completely remove this statement
09:38Now a special thing
09:39This chapter
09:40It is not only functions
09:41This chapter
09:42It is functions
09:43And methods
09:44What are the methods
09:45Which functions
09:46We write classes
09:47They are methods
09:49So functions
09:51And methods
09:52Are the same thing
09:53Now in C++
09:54We can write functions
09:55Out of the class
09:56But as Java
09:57Designed
09:58The whole code
09:59In the class
10:00That is why
10:01This function
10:02Is written in the class
10:03In Java
10:04Basics
10:05That is why
10:06We will call this function
10:07Conventionally
10:08Method
10:09But if you call this function
10:10Or method
10:11It is no practical
10:12As such
10:13Usage
10:14That is the proper term
10:15You need to know
10:16That is why
10:17The functions
10:18We call methods
10:19This chapter
10:20That is the name
10:21Functions
10:22Methods
Be the first to comment
Add your comment

Recommended