 Okay, welcome to intro to AP computer science for new AP teachers. This lesson is about strings So we're gonna talk about what is a string again? I'm sure you know, but just kind of how do you describe it to students? Talk about concatenation and some of the things you need to watch out for there The string methods there's yeah, of course There's lots and lots of string methods, but the AP only really requires that you know I think about five of them So it's kind of a nice really nice subset of the actual string methods and I'll talk about like an introductory exercise or two You can try with your students. So what is a string? So for the students, this is where we emphasize that this is our first non primitive type and Part of the way that we know that is that string is capitalized for all of our primitive types, you know int double Boolean they are all lowercase and that is that's an important distinction that gives them a little bit of information About that particular object So they just let know it's data type that holds textual data and so that'd be like a first name last name You know that sort of thing and then the data. I mean, it's kind of obvious, but the data is in order There's a difference between a B and C and there's a difference between that and CB and a even though they have the same letters They would be different because there's a different order It bears repeating just because it has implications later in the array units and this is really where I start to Introduce the idea of a collection So a string is our first like kind of collection that we're looking at this This is such an important concept when we get into iteration And then later we get into arrays and array lists and 2d arrays just having to iterate through a Set of objects through a collection of objects, you know perform some sort of test This is a big big thing on that AP exam So I really introduced it here and then when I bring it up later I always refer back to well just like we did with strings. We can do this with our arrays We can do this with our array lists. It just kind of builds that concept up throughout the course Concatenation is just a fancy way to say combining strings and to do that We use the plus operator and one thing again with beginners is they might not know the difference between say first plus Last and you always print that out and show that there's no there's no space and sometimes kids are like well Where's the space like well you didn't put it in there and then so that needs to be explicitly added So first plus quote space quote plus last I shouldn't put quotes last there and I'm not gonna go back and fix it Trust me know that It was really important to note that quote to quote plus quote to quote is 22. It is not for So I do go through and I walk the students through that I say look There is a difference between the date This is where data types matter and you might also want to show them You know what's two plus two point zero to show them what happens is it is it come out as an int It's come out as a double. It's kind of an interesting You know thing to see where their minds are if you ask them and then escape characters These are the slash characters. So n is next line T is tab if they want to actually print a backslash They need to do slash slash if they want to print inside double quotes They need to do slash quote and then depending on how your computers are set up Slash a will actually play a little bit of a beep or like a the terminal sound depending on what kind of computer You're using I think it's kind of it starts to get you know, they like to make sounds basically So string methods strings are objects. So they have methods So this is one thing that kind of sets the primitives apart from objects that later talk about, you know Integer classes and the auto boxing all that sort of thing and that is part of the AP But for now to say look, well, it's an object. So just like human beings You know you can sleep in class, but you shouldn't you can talk to your friend, etc There are things that strings can do so again subset here is length Substring index of equals and compare to so Some of the things I'd like to really be careful about emphasizing is that substring is used to take one part of the whole at a time So this is what I use for iterating through a collection of strings or of a string So we can look at each letter individually. So for example, is it a vowel? Is it a number so we can start categorizing and determining membership with using index of as The next one. So when I say determined membership, so I might do like a list of vowels. So vowels equals a e i o u capital a e i o u and then using index of we can determine is a letter of vowel So if it's in there, you know, so the index is greater than negative one It is a vowel if it's less than if it's less than negative or equal negative one I should say less than zero. It is a Not a vowel and then also this is an important place to bring up that the dot equals method is different to equals equals with objects so the way that objects are compared is very different to the way that Primitives are compared and again my e-book talks about this in much more detail So quick introductory exercise or two here So basically just like we did before with primitives choose a real-world object and write some strings to describe it And also primitives to review. So for example You know, like if you're doing a mobile phone might be, you know, case color so string case color equals in my case It is green. So what you know, how can we describe objects using strings not just numbers now? But now we can actually use a descriptive term and then also one other way is we could write the names of the seniors in one string So, you know Bob, you know Bob space Sue space Jason Inside of a string called seniors and then use index up to determine membership So is so is Bob a senior? Yes, because the index is greater than negative one and we might say is No, you go a senior and you say no because the index of that is negative one so we're just getting the students used to that idea of sets of collections getting students use the idea of testing so we have a condition we want to know How does how do these things relate and I find this skill is really really useful Especially later like I said and answering the free response questions on the AP exam So yeah, so we covered what is a string concatenation string methods the five that are focused on in the AP and Just some things to watch out for when you're teaching this and because that'll come in handy later I didn't know this my first year so it's a new wilder come up with this to see how it all kind of fit together And then there was a nice little hopefully nice little introductory exercise or two to help you get started So thanks for watching. See you next time