1 00:00:00,600 --> 00:00:01,930 Hailes the strings are the hardest. 2 00:00:01,930 --> 00:00:05,870 Once again welcome to the next video of Codlin fundamentals. 3 00:00:05,890 --> 00:00:12,980 Now in this video let us not proceed and check out what is the syntax to define functions in Coquelin. 4 00:00:13,000 --> 00:00:18,110 So our typical method in case of Codlin appears to be like this. 5 00:00:18,220 --> 00:00:21,040 So we have a keyword this matter name. 6 00:00:21,130 --> 00:00:24,100 These are the arguments and this is the return type. 7 00:00:24,250 --> 00:00:26,700 And then here we return something. 8 00:00:26,740 --> 00:00:33,710 So our typical method in case of Cartland has some syntax such as this is the one keyword. 9 00:00:33,760 --> 00:00:35,520 This is the method name. 10 00:00:35,590 --> 00:00:39,760 These are the formal parameters such as length and breadth. 11 00:00:40,120 --> 00:00:45,080 And here are the end I have returned by now to define a return type. 12 00:00:45,100 --> 00:00:52,240 You have to simply use a colon followed by a space and followed by the return type such as integer string 13 00:00:52,390 --> 00:00:54,080 boolean and so on. 14 00:00:54,430 --> 00:01:00,400 And now here with the help of this method we are actually finding the area of a tangle or something 15 00:01:00,490 --> 00:01:02,000 like that. 16 00:01:02,050 --> 00:01:08,860 So here I am simply returning length into bread which is equivalent to integer value that we have defined 17 00:01:08,920 --> 00:01:10,030 here. 18 00:01:10,030 --> 00:01:15,520 Now apart from the don't die the methods can also return void. 19 00:01:15,520 --> 00:01:16,150 That is. 20 00:01:16,210 --> 00:01:18,270 It has also got the right to return. 21 00:01:18,310 --> 00:01:22,520 Nothing so far that the syntax is this right. 22 00:01:22,600 --> 00:01:26,700 So here function fine area length and breadth. 23 00:01:26,920 --> 00:01:31,110 And here instead of void in Cartland we are using Unix. 24 00:01:31,330 --> 00:01:36,410 So this unit is actually equivalent to the void in Java right. 25 00:01:36,520 --> 00:01:41,950 So if you don't want to return anything in Scotland then simply use galloon space unit. 26 00:01:42,190 --> 00:01:44,840 No aspell the Cartland Gordon convention. 27 00:01:44,860 --> 00:01:50,250 If you'd done nothing then you don't need to define this unit explicitly here. 28 00:01:50,320 --> 00:01:55,220 By default if you don't define anything here then also the code will work. 29 00:01:55,360 --> 00:01:58,740 So if you want to you can also remove this unit from here. 30 00:01:58,750 --> 00:02:05,040 It is of no use and now inside the intelligent ID inside our Kaytee file. 31 00:02:05,130 --> 00:02:07,730 Let us try to write our first function. 32 00:02:07,780 --> 00:02:12,040 Let's see if you are in space a function to add two numbers. 33 00:02:12,100 --> 00:02:16,770 They simply define the method body and radio record inside this. 34 00:02:17,020 --> 00:02:25,990 So here I would simply define the variable of let's see a equal to two and then that would be equal 35 00:02:25,990 --> 00:02:27,220 to let's see forward. 36 00:02:27,370 --> 00:02:31,510 And now here I will simply print though some of these two numbers. 37 00:02:31,610 --> 00:02:37,970 Or if you want you can also define that sum equal to a plus b like this. 38 00:02:38,140 --> 00:02:46,480 And then finally and then finally at the end I will simply print the sum such as some is let's see a 39 00:02:46,660 --> 00:02:48,850 list B on insert of this. 40 00:02:48,850 --> 00:02:51,250 You can also use the entire politian. 41 00:02:51,380 --> 00:02:56,100 That is the string in the politian actually studied in the previous videos right. 42 00:02:56,180 --> 00:03:01,240 So curly bracket open and close along with a prefix of a same. 43 00:03:01,450 --> 00:03:04,550 And I guess I forgot to use some very well here. 44 00:03:04,690 --> 00:03:07,370 So as of now let us remove this right. 45 00:03:07,480 --> 00:03:09,060 So this completes our called. 46 00:03:09,070 --> 00:03:13,150 Now the question arises from where we are going to call this method of error. 47 00:03:13,330 --> 00:03:16,780 We don't have any main method defined in case of Cartland. 48 00:03:17,020 --> 00:03:23,260 So here I would simply define my toplevel main method which is actually equivalent to public static 49 00:03:23,260 --> 00:03:23,950 void main. 50 00:03:23,950 --> 00:03:29,960 In case of Java programming so let us define the fun main here. 51 00:03:29,960 --> 00:03:34,100 Just go on Adye of string. 52 00:03:34,120 --> 00:03:35,590 Right as simple as that. 53 00:03:35,710 --> 00:03:42,520 And we already know all these things from the previous values of discourse so simply call this ad Metford 54 00:03:43,120 --> 00:03:45,070 And now let us run the code. 55 00:03:45,070 --> 00:03:50,170 And remember this main method is actually the entry point of your application. 56 00:03:50,350 --> 00:03:56,270 So this method will simply call Add method which in turn will simply print apers be sorted out and the 57 00:03:56,270 --> 00:03:58,810 called in the output. 58 00:03:58,820 --> 00:04:04,220 We have some is 6 and now let us make it print LN and then run the code again. 59 00:04:05,350 --> 00:04:07,500 So this makes our output better. 60 00:04:07,600 --> 00:04:08,110 Right. 61 00:04:08,370 --> 00:04:13,120 And now if you know this here this argument does not return anything. 62 00:04:13,120 --> 00:04:19,150 So here you can also use clone space unit which is actually equal into void. 63 00:04:19,150 --> 00:04:25,500 In case of Java no aspell that Cartland coding convention you don't have to specify you need. 64 00:04:25,720 --> 00:04:27,480 If you don't return anything. 65 00:04:27,520 --> 00:04:30,380 So by default every method returns unique. 66 00:04:30,460 --> 00:04:31,330 That is weird. 67 00:04:31,480 --> 00:04:34,720 So you can remove it and it will work perfectly fine. 68 00:04:34,720 --> 00:04:35,360 Right. 69 00:04:35,740 --> 00:04:39,890 And now suppose I want to pass these two variables as paramita. 70 00:04:40,030 --> 00:04:41,610 So for that part I really do. 71 00:04:41,620 --> 00:04:49,500 I will simply pass to my food here and now let us remove these two lines of code and then specify variable. 72 00:04:49,510 --> 00:04:56,930 A clone of the type of and comma variable be all of the type of end. 73 00:04:57,140 --> 00:05:01,040 And now here I am simply printing all the values inside the function. 74 00:05:01,040 --> 00:05:02,540 And so let us know. 75 00:05:02,590 --> 00:05:07,550 And they're called So this is how we pass the argument in case of Cartland. 76 00:05:07,570 --> 00:05:09,260 So some is sixth grade. 77 00:05:09,400 --> 00:05:16,300 And now suppose our requirement is that let us bring this statement inside the main method not here. 78 00:05:16,300 --> 00:05:22,600 That is we want in return the sum of these two numbers so far out of our day will do is I will simply 79 00:05:22,600 --> 00:05:29,770 use that sum equal to add two numbers and then I will simply correct this statement and paste it here. 80 00:05:30,010 --> 00:05:38,270 And instead of this let us use let's say dollar some light that string politian Or alternatively you 81 00:05:38,270 --> 00:05:40,860 can also use less. 82 00:05:40,930 --> 00:05:41,530 Right. 83 00:05:41,840 --> 00:05:43,860 So no issue in this as well. 84 00:05:43,880 --> 00:05:49,510 Now here I have to return the sum of inby so that I can print it here right. 85 00:05:49,580 --> 00:05:59,650 So far that I have simply written legacy return a less B and now it simply shows an error type mismatch. 86 00:05:59,720 --> 00:06:03,320 Now the return type is Bideford is unique. 87 00:06:03,320 --> 00:06:06,110 Now here we are returning the endangered value. 88 00:06:06,110 --> 00:06:09,770 So instead of unit latest type capital I N D. 89 00:06:10,040 --> 00:06:16,320 So this method simply returns the sum of these two numbers and still it inside the very the variable 90 00:06:16,320 --> 00:06:16,840 the sum. 91 00:06:17,000 --> 00:06:18,800 And then we print it out here. 92 00:06:18,980 --> 00:06:19,680 So let us know. 93 00:06:19,700 --> 00:06:21,460 And they're called. 94 00:06:21,490 --> 00:06:23,550 So here we get some is 6. 95 00:06:23,680 --> 00:06:28,630 So this was all about the basic syntax for the functions in case of Cartland. 96 00:06:28,630 --> 00:06:30,580 So get you guys in the next video. 97 00:06:30,580 --> 00:06:31,420 Thanks for watching. 98 00:06:31,420 --> 00:06:32,290 Have a good day.