1 00:00:00,000 --> 00:00:04,793 [MUSIC] 2 00:00:04,793 --> 00:00:05,856 Hello and welcome. 3 00:00:05,856 --> 00:00:07,840 I'm Craig, and I'm a developer. 4 00:00:07,840 --> 00:00:12,510 For this course, it doesn't matter if you have any programming experience at all. 5 00:00:12,510 --> 00:00:15,890 I'll be introducing you to some very common tools available in 6 00:00:15,890 --> 00:00:18,140 almost every programming language that you might encounter. 7 00:00:19,160 --> 00:00:23,060 We'll be doing our exercises in Java, and I'd like you to approach this 8 00:00:23,060 --> 00:00:26,040 as if you were attempting to learn a foreign language. 9 00:00:26,040 --> 00:00:30,330 I'll introduce you to the rules or syntax of the language as you need it, 10 00:00:30,330 --> 00:00:32,590 we will also discuss the oddities that you might encounter. 11 00:00:33,650 --> 00:00:36,010 As we go through different parts of this course, 12 00:00:36,010 --> 00:00:40,120 you'll start to recognize words and concepts in other parts of the language 13 00:00:40,120 --> 00:00:42,370 much like you would in a language immersion program. 14 00:00:43,500 --> 00:00:46,270 Just like when you're wandering around a foreign country where you're just 15 00:00:46,270 --> 00:00:48,780 learning the language, you'll come across words and 16 00:00:48,780 --> 00:00:52,370 phrases that you aren't familiar with and that's okay. 17 00:00:52,370 --> 00:00:56,170 Focus on the topics we're covering and don't worry about the other parts. 18 00:00:56,170 --> 00:00:59,600 As we're cruising along, I might ask you to ignore some things, but 19 00:00:59,600 --> 00:01:01,469 I promise we'll get back to it when the time is right. 20 00:01:02,600 --> 00:01:06,490 You might not have noticed it yet but there is speed controls on your video. 21 00:01:06,490 --> 00:01:09,910 Please feel free to speed me up and make a pretty good chipmunk or 22 00:01:09,910 --> 00:01:14,600 slow me way down as you feel necessary. 23 00:01:14,600 --> 00:01:15,640 I won't take any offense. 24 00:01:15,640 --> 00:01:16,860 I promise. 25 00:01:16,860 --> 00:01:19,320 Also, I've added helpful links in the teacher's notes 26 00:01:19,320 --> 00:01:21,750 that will allow you to learn even more, sound good? 27 00:01:23,010 --> 00:01:27,290 So without further ado, let's get started with our task at hand. 28 00:01:27,290 --> 00:01:29,380 Just like most foreign language classes, 29 00:01:29,380 --> 00:01:33,080 the first thing we're going to learn is how to introduce ourselves in code. 30 00:01:34,170 --> 00:01:38,420 So, what we'll do is we'll write out or print, hello my name is, and 31 00:01:38,420 --> 00:01:40,540 then your name, to the screen. 32 00:01:40,540 --> 00:01:42,210 Speaking of introductions, 33 00:01:42,210 --> 00:01:47,250 allow me to introduce you to where we'll be coding during this course, Workspaces. 34 00:01:47,250 --> 00:01:50,080 If you click the launch Workspaces button right next to this video, 35 00:01:50,080 --> 00:01:53,560 you'll see a new browser open with our programing environment. 36 00:01:53,560 --> 00:01:54,310 I'll head over there with you. 37 00:01:56,090 --> 00:01:59,120 So this is a Workspace, and it's all yours. 38 00:02:00,330 --> 00:02:04,220 You'll see up here that there's a tabbed interface of files that you have open. 39 00:02:04,220 --> 00:02:07,540 And over here is a list of files that you have available to you. 40 00:02:07,540 --> 00:02:08,760 I've gone and created a file and 41 00:02:08,760 --> 00:02:12,120 got it all set up with a nice starting point to begin writing our application. 42 00:02:12,120 --> 00:02:13,830 It's called Introductions.java. 43 00:02:13,830 --> 00:02:14,931 Let's open it up and take a peek. 44 00:02:18,521 --> 00:02:21,070 I've left a note or a comment right here. 45 00:02:22,070 --> 00:02:25,380 Comments in Java start with two forward slashes, 46 00:02:25,380 --> 00:02:27,820 everything after the slash was ignored by Java. 47 00:02:27,820 --> 00:02:31,660 So they're used by programmers to explain what their code is trying to accomplish in 48 00:02:31,660 --> 00:02:34,910 clear English or to leave notes for other programmers. 49 00:02:34,910 --> 00:02:38,265 Now one goal of programming is for your code to be as clear as possible, so 50 00:02:38,265 --> 00:02:39,975 that it doesn't require comments. 51 00:02:39,975 --> 00:02:43,475 However, as we're getting started here feel free to leave comments whenever you 52 00:02:43,475 --> 00:02:46,330 want to remind yourself of what it is that we're attempting to do. 53 00:02:46,330 --> 00:02:49,462 Now, remember how I warned you that you'll come across words or 54 00:02:49,462 --> 00:02:52,594 phrases that you aren't familiar with and that I might ask you to 55 00:02:52,594 --> 00:02:56,850 ignore some parts of code until later, we're at one of those points. 56 00:02:56,850 --> 00:02:59,510 Every Java program has some setup that needs to happen and for now, 57 00:02:59,510 --> 00:03:00,460 I've done that for you. 58 00:03:00,460 --> 00:03:03,430 But don't worry about understanding most of the pre-written code that's on 59 00:03:03,430 --> 00:03:06,750 the screen, it's just the setup that we need to do to start writing our own code. 60 00:03:07,840 --> 00:03:11,480 However, the one bit of code I've written that I want you to take a closer look at 61 00:03:11,480 --> 00:03:12,700 is this line right here. 62 00:03:14,040 --> 00:03:17,100 But don't worry exactly about how this code works. 63 00:03:17,100 --> 00:03:21,100 What you need to know is that it creates a Java object, which we'll talk about later, 64 00:03:21,100 --> 00:03:23,650 which has a method that allows us to write out 65 00:03:23,650 --> 00:03:25,700 text to the terminal which is down here. 66 00:03:26,930 --> 00:03:30,320 I'd like to take a quick break and already acknowledge, as well as remind you that I 67 00:03:30,320 --> 00:03:34,780 just threw out a mouthful of new terms like objects and methods and like I said, 68 00:03:34,780 --> 00:03:38,080 don't worry, we'll cover them in much greater detail in the following course. 69 00:03:38,080 --> 00:03:42,330 But for now, I just want you to continue immersing yourself in this language. 70 00:03:42,330 --> 00:03:45,430 I'll explain the concepts when they're important to the task at hand. 71 00:03:45,430 --> 00:03:50,320 So like I said thanks to the setup I've done, we have access to the console object. 72 00:03:50,320 --> 00:03:53,700 We can use this console object to print text to the screen. 73 00:03:53,700 --> 00:03:57,800 Objects like console have methods that let them perform actions, and 74 00:03:57,800 --> 00:04:01,135 the action that we want to do right now is print some text to the screen. 75 00:04:01,135 --> 00:04:05,610 Console's method for printing text on the screen is called printf, so let's use it. 76 00:04:07,496 --> 00:04:09,990 First we'll type console, and 77 00:04:09,990 --> 00:04:13,360 then a period to access its methods, then the word printf. 78 00:04:14,610 --> 00:04:17,430 We're gonna call the method by doing open parenthesis. 79 00:04:17,430 --> 00:04:21,060 Now we're gonna do double quotes and write the text out that we wanna write, so 80 00:04:21,060 --> 00:04:24,680 we're gonna say, hello my name is Craig. 81 00:04:24,680 --> 00:04:28,692 We're gonna end the double quote, and then we're gonna end the parenthesis and 82 00:04:28,692 --> 00:04:32,527 then we're gonna put a semicolon to signify that the statement is complete. 83 00:04:32,527 --> 00:04:36,462 You might have noticed that as I edited the file there's a little dot up here 84 00:04:36,462 --> 00:04:38,723 signifying that the file has been edited. 85 00:04:38,723 --> 00:04:41,124 I'm going to go ahead and I'm going to save from the file, 86 00:04:41,124 --> 00:04:43,721 I mean I'm going to click File, and I'm going to click Save and 87 00:04:43,721 --> 00:04:46,820 you'll notice that in the future you can use Cmd+S or Ctrl+S on a window. 88 00:04:48,170 --> 00:04:50,420 Okay, so let's see our code in action. 89 00:04:50,420 --> 00:04:52,110 Now, Java is a compiled language, 90 00:04:52,110 --> 00:04:56,100 which means that we have to run a compiler program to turn our human readable Java 91 00:04:56,100 --> 00:04:59,600 code into computer readable code before we run it. 92 00:04:59,600 --> 00:05:02,970 So let's compile our introductions program. 93 00:05:02,970 --> 00:05:07,688 To do that at the console, we type javac and 94 00:05:07,688 --> 00:05:14,000 then the name of the file which is Introductions.Java. 95 00:05:14,000 --> 00:05:17,190 Java C is short for Java compiler. 96 00:05:17,190 --> 00:05:20,940 So this line is telling the Java compiler to convert or compile 97 00:05:20,940 --> 00:05:24,960 the code in the file Introductions.Java into an executable file. 98 00:05:26,590 --> 00:05:27,570 So I'm going to press Enter. 99 00:05:29,590 --> 00:05:33,600 And if we take a look at the files in this directory using the LS command, 100 00:05:33,600 --> 00:05:39,490 see that there is now a file called Introductions.class. 101 00:05:39,490 --> 00:05:42,810 By the way, I should mention here that LS stands for list, and 102 00:05:42,810 --> 00:05:44,850 it allows you to list files in a directory. 103 00:05:45,860 --> 00:05:48,050 We're gonna use a few terminal commands on this course, and 104 00:05:48,050 --> 00:05:50,090 I'll teach you everything you need to know for it. 105 00:05:50,090 --> 00:05:52,910 But if you wanna learn more about using the terminal, check out our 106 00:05:52,910 --> 00:05:56,430 course called Console Foundations which is linked in the teacher's notes. 107 00:05:56,430 --> 00:06:01,975 Now to run our program, we simply type java Introductions. 108 00:06:04,660 --> 00:06:08,340 Now notice the command that I type here is java, not javac. 109 00:06:09,570 --> 00:06:14,676 Java runs the program it only needs the name of the class, without the extension. 110 00:06:14,676 --> 00:06:18,842 Javac required that .java, and Java does not. 111 00:06:18,842 --> 00:06:20,810 So I wanna press Enter. 112 00:06:20,810 --> 00:06:24,569 And here on the screen we see our output, the introduction. 113 00:06:24,569 --> 00:06:25,690 Great job. 114 00:06:25,690 --> 00:06:28,180 We now have our first compiled program. 115 00:06:28,180 --> 00:06:30,149 You've been learning a ton. 116 00:06:30,149 --> 00:06:32,133 Before we move on and learn even more, 117 00:06:32,133 --> 00:06:36,312 let's do an exercise to review some of the things we've learned thus far. 118 00:06:36,312 --> 00:06:40,667 Before we get there, let me just remind you that there is a community that you can 119 00:06:40,667 --> 00:06:44,230 and should lean on while going through this course. 120 00:06:44,230 --> 00:06:47,800 If you have questions, it's likely someone else has them too and 121 00:06:47,800 --> 00:06:50,180 has maybe even answered them. 122 00:06:50,180 --> 00:06:51,890 Learning how to ask questions and 123 00:06:51,890 --> 00:06:55,200 find answers is in my personal opinion the best way to learn anything. 124 00:06:56,610 --> 00:06:59,310 If you're coming to this course with some Java experience, 125 00:06:59,310 --> 00:07:03,400 you might have used an IDE or Integrated Development Environment. 126 00:07:03,400 --> 00:07:06,670 Now those are a set of tools which greatly simplify the development 127 00:07:06,670 --> 00:07:11,060 process through code completion and many other bells and whistles. 128 00:07:11,060 --> 00:07:13,280 As handy as IDEs are, 129 00:07:13,280 --> 00:07:16,250 I'd like to request that you still follow along in the Workspace. 130 00:07:17,370 --> 00:07:21,300 As I think there's benefit in learning and gaining confidence in doing things 131 00:07:21,300 --> 00:07:24,342 all by yourself and removing some of the magic of that IDE. 132 00:07:24,342 --> 00:07:28,635 We'll go over IDEs in a future course when the time is right. 133 00:07:28,635 --> 00:07:30,190 Okay, now back to that exercise.