In the previous lesson, we discussed what is this class and how to clear the data members and the how to create the class methods and how to create the object of it, and how we can call the different method using my object. So this was concepts we can see a different type of data type called supported by Salesforce that we have seen. So now today, we'll discuss more conceptual topics like we are going to discuss about what is concerned in Salesforce, like in our test, in writing, how I can create a constant variable called Can I can say I can say, what is constant, okay, and how to manipulate the expressions. And we'll see how to use the conversion. I'll talk about each one each individual topic one by one, and we'll see how we can use the control flow statements. Do the very basic things we'll discuss.
And we'll use these basic things in accounting systems. So see, in the previous example, when we did I disclosed when I want to create a variable what I need, I need a data type and my variable name, then optionally, I can assign some value to it. Am I correct something again, then I can assign. So now like, if I want to declare integers, number four, they do. My data type is integer. Let's see, variable name, I gave us a number.
Then I want to assign some Hello, I say Dustin, okay. And again, I can write some more logic, some more logic I can write okay. And after writing again, if needed, I can set the value of this variable to 20. Also, again, same way, I can write many more logics again, my programming you can write again, I can say it variable value 215 also see the variable number initially had value 10 then I said to 20 then I said to 15 Okay, this will be what I'm reading. So now let's see I want this variable whatever I have I want this variable value should not be changed, okay, should not be changed after initialization of it. If they want to like this, what will happen?
But what Okay, let's see, I have I want to like this I want to create an integer variable, nothing but number and I didn't set any Well no, I wrote some piece of logic and writing some dummies that statements in the form of some logic, and then I'm going to say it number was 10 for example. Now again, I can write some logic and wherever you go, again, you are not allowed to update the value of this one. So if you want this kind of Then we can go for constant we have declared the constant how we can declare the constant. So, whenever you want to declare any constant, simply what you have to do, you have to use one keyword, which we call constant. Okay? constant you would have to use.
So if I want is integer number one to be convert to constant what I have to do, I have to write like this, okay, sorry, it's not constant, I have to use keyword final. Okay. So what I have to do, I have to define final integer less number. So this is nothing but a number variable of type integer, which is final dice. So, that means once I set a value to it, I cannot add any more values, but I cannot update the values. Let's see how it's going to happen.
So, I'm in the writing I'm in the sulfus. Okay, I'm going to open my Developer Console, you can use any IDE Whatever you have, you can use your Visual Studio code. You can use your poster, comm ID or Developer Console, or any way you acida you like this. Also, you can use whatever ID you want you can use. For our example, I'm going to my Developer Console. Okay?
I'm just going to write some piece of anonymous code. Okay, as I said, I'm not going to save this code, simply I will execute. So anyhow, in upcoming session, I will explain what this what this Developer Console going to do for us. But for now, I'm going to write some piece of anonymous code. So I went to my debug. From here, I open execute anonymous window.
So I'm just holding everything here. But what I want, see if I want to create a integer, I just specify here, integer number equal 10. Then again, I get let let me make a statement here to debug any messages. In the log file. I can print like this. Okay.
Try the system to debug, then I want to see what is the value of number. Okay, now let's see, I don't have any value. So now what I can do, I can come here, then again, I can set the value of number of skin. Let's see, I want to set so that base image after fast insulation, what is the Hello coming here? See my number. For now say, Molly.
I'm just going to in update this number hello to something else. So say he may update the manual is going to be 20. And he may say after a second initialization, the hell is 10 or 20. What is the hell do I have right now? So is this a one to operate or not? That's a second initialization I was just going to do going to do it.
For now I'll see. If I go and executed what is going to happen and I'll see in the log what is happening. So I have declared one number variable of type integer and in there I have said value 10 and then I have silver boundary. That means once I initialize a value, and also I'm trying to automate, so say it's a normal normal variable who to declare for now either a goatee operator, obviously nimbo number is a number. No, it is not like this. It's a keyword.
Let's see, I'm just using like this. No, it's my fault. Okay, see. So other keywords you can use as a variable name, that also you saw here. So you have to use non keyword words to be declared as variable. Okay, I click on execute my this piece of code executed, we'll see parties coming on my log file.
I open my developer console here. Then I click on my debug only statements. See, initially my value was null. You can see past I don't have any value assigned to number variable. No, but I've been so in a print they say no, the value is coming along. It's nothing There.
So now I assumed it was 10. So you can print it, you can see Ellucian you can see the statement passed in is an insulation number 10. And again, I initialized or you can say I modified the value to 20 with the same variable, I'm just updating the value. So now they're looking into 20. So see, now that means I can modify the value again and again whenever I want, if I want, okay, now, once you initialize, you are not allowed to modify. Simply I have used the keyword callers final, something I wrote.
Finally, it's a keyword. So I define the solar panel. Now if I try to Google what is happening, see, it swings an exception is system final exception. Final variables already been initialized. That means you've seen you have been already initialized hello to my final variable. Up on this document.
There is a final variable to declare cause Name is no number. So I have initialized the number Hello at line number three. And again, I'm trying to initialize or trying to update the value on line number five, so it's not alone. So, I cannot I cannot have this piece of code also, or I cannot run this piece of code. Because final variable, you can insulate only once. You see, I just commented this line code, and now I'm trying to do it now I'm successfully able to do so, once you initialize value of any final variable, then that became constant.
So no nowhere in the same transaction can be updated by any logic or body nature, the value of this variable Is this clear? This is basically recall constant if you want to declare any constant, then you can declare like this. Okay. I saw you know, coming to sort of I know take a examples of writing trigger or any of this. Let me let me For you, how am I going to use this final constant variables on my program? Okay, just now understand the concepts Manasa look at any question on this content but you're no devices.
So only thing one thing right? So we never use the phonetic keyword the variable becomes constant constant till it will allow only to initialize one see I have initialized here alone. And in the point I declare I didn't set any value. That means I didn't initialize anything. If you see this program we run right now it is executing. It's fully integrating, but see if I initialize some value here now and again also the insulation statement of same variable on line number three, if I try to execute Okay, it's not alone.
So only one time in insulation can be done. Only one time you can insulate you, this same variable up for the final or you can say of constant variables cannot be detail is multiple times Okay Okay. Perfect for now see okay let me any question from this part already see here Okay, that's fine okay I think it was not able to hear us in spite of noise. So you understand what is the construct and in the construct we understood okay? The variable whose value do not do not change after being initialized that we call mine constant variables. Okay, I'm just giving this note for you, so that I can now share with you okay.
So you can can use you know, when you practice or when you want to refer you can you can use this notes Okay, I'm just giving you Okay, perfect. So we understood how I am going to declare any constants or any a variable called Hello cannot Be more prepared after being incentivized okay. So, now, if you remember in the previous session, we have discussed many datatypes let me show you that we have discussed like my blog, my Boolean my date or integer long my things, okay. So now whenever we have many data is what is going to happen, let me see something like conversion how this conversion going to work? Okay. Now by using the conversion rules, see, I have this is again the basic concept which we need to know for operating systems.
Let's see, I have one integer variable, let's see, integer number on every integer number one. Okay. I have some ello, which we'll call 100. Okay, and also I have another another variable double CD numbers. Okay, and I want this number one should be copied to number two. Okay?
So nothing but my number one is one. And also let's see, I have one belt one variable called string and the letter C i said str one point I stoled something like sensors. Okay. So can I stole the str at one value to my integer type of variable? If I have one more integer? Let's see.
I end one. Can I store my SPR one there? It is, hose. hose value is stored in SQL one variable. Can this str str one can be initialized to integers? No, no because was as I explained in the previous lesson, what I said it's basically it can store the same type of record.
So now being the st wanting a string type I am not able to assign an integer, but there is also some kind of conversion rule. So, what you can do, if you want to convert one type to another type, what kind of things we can do what kind of things we need to consider, for example, this integer number and I have double, but double can store hundred Also, I'm incorrect, nothing can So, number one here. So, not double or long can take my integer value also, when I say let's consider I have one decimal point, can I define in decimal number equal to hundred? Is it possible or not? is we can is that means this hundred nothing but my initial value correct. You see there are some some something which we can automatically assign interior to the female I can do or My integer double also we can do so what I'm trying to say here whenever you have this kind of thing.
So, the variable of lawyer type I will define what is a lawyer type variable of lawyer numeric types can be I say into my higher type without any explicit deconversion Okay, there are many methods which I will talk in upcoming sessions they are tangled giving you basically copied Okay. So now, when I say lawyer, I'm just giving the sequence of the lawyer integer is my lawyer numeric type after integer my entire is nothing but long Okay, like though these are primitive datatypes what we have listed out in the previous system, okay, then same way I have double, then I have decimal okay. So see any deserve a low you can assign too long automatically the integer is a loyal loyal part long can store an integer and also long can be stored in in in double and any double can be stored in decimal without loss of any data.
So, now in the integer if I have 100 that hundred can be stored in long also okay and that double can be stored in that Canvas and that hundred can be stored in the same way if you see it has a long part if I have some long integer okay drama. So, can this be also if this long integer it cannot eat may not store an integer, it may not fit in the size, but obviously it will fit in the double and also it will teach on the decimal also. Okay, so same I even go to double Okay, let's see Something like this or you know, okay. So, in this double value what I have it can be easily accommodate to my decimal value okay without any explicitly cumbersome simply I can assign like this, okay, but the thing is I try to assign my decimal value to integer let's see our let me make little small 123 decimal six seven, if I have this kind of value, Okay, can I store this value in integer, if I am going to store my decimal point is going to be truncated going to last somewhere.
So I cannot store 1.3 3.67 in manager manager can store only one policy method. So that means if I try to convert from higher type to lower type, then we may have lost the loss of data. Okay also very low. So if you see in the decimal I have I can still one to a punch even if I try to convert that to integer I may have only 123 Okay. So, I will say there are many methods on each type of integer arithmetic class for us, there are many methods how we can convert from one type to another day. So, now, what are the basic what I'm saying we can convert one data type to another type, there are some types which are known for is no need of external conversion method we can explicitly convert by assigning from lower to higher.
So, if I have an integer variable number one that can be assigned to double simply by writing a extrusion statements like this number one can be assigned to a double variable. So, same way any lawyer type can be assigned to a higher type explicitly okay and he will try to assign any higher type loci, it may lose some data, I will show you how we are going to assigning all these kind of things, okay. So when you go to each individual classes that might show you how we're going to do it. Any questions along the way? Minus, trust me. I'm good.
Thank you. Yep, perfect. Okay, so now we are going to