Bluej programming language12/31/2023 You can give it whatever name you want, I'm just going to leave that name there. So now we can right click on that and create an instance, or an object. If everything works good, you see the slanted lines disappear, except for just the two in the right corner, and then that means it's compiled, it's created the class file, which is a machine readable code that the computer understands. So we will right click here, and there's a compile, so we'll compile it. You need to compile the program so your computer can understand it. You can see all the diagonal lines there, that means we haven't compiled the program yet. In order to run the program, we are going to right click on Hello World here. We're going to assign that line to the variable called line, and then you can see the line inside the four loop is going to print that line. We are going to assign it to a file resource called RES, and then what we're going to do is, we're going to loop over the file, so we have a four loop where we are going to, every time we call the file resource RES, res.lines, it gives us another line from the file. So we're going to create a file resource, and you can see, we're going to tie it to the file called hello_unicode.txt. Each line in the file is a greeting from some country. What we're going to do is, we are just going to open up a file and we're going to print every line in the file. So this is a class, HelloWorld, and it has one method in it called runHello. I'm just going to scroll over so we can see a little bit more. So let's click on that and see what's there. Once you have it there you'll see Hello World. And, for me, I've already got the program there, but if you don't see it, you may have to click up here on project, and open project, and you'll have to go to where your project downloaded to, which folder it's in. I'm going to click here, and BlueJ is going to start. So you should have already installed BlueJ. So if you just click on that, it's a ZIP file, a nd you will just unpack it and you'll have everything there. I'm going to click on that, and that is going to give you the Java program and the data file. And here you can see our first program called Hello World, The Blue J Project. Since we're going to run a particular project, we'll click on project resources. There's lots of resources that we have provided for you on this website. And we're going to go to course two, and click on there. So I have the Duke Learn to Program website up right here. We're going to show you how to download it from the Duke Learn to Program website, and then open up BlueJ, and run the program. You're going to run your first Java program. And we've added some special features that you'll use as you develop Java programs for this course. It allows you to start programming without having to worry about editor complexities. We choose BlueJ because it's a great programming environment for novices. In these courses, we'll be using a particular environment called BlueJ. So, where do you write this code that will eventually be run by the computer? Programmers write code in programming environments. When you write Java programs, before you run your program you will need to compile it. This process of translating source code held inside classes into bytecode is called compilation. Now, in order for the computer to run my program, my source code must be translated into low level byte code, which is machine readable. Source code is high level code, which is human readable, but not machine readable, so when I open this Java class here, I can read the Java program one of my fellow instructors wrote in it. The code you write is called, source code. In a Java class, you will write one or more Java methods, instructions for your computer to carry out when you run the program. We'll learn more about objects, and object oriented programming, in the next course. Classes are a way of organizing your programs, and objects are created using classes when your program runs. Java is an object oriented language, this means you'll use classes and objects in writing your code. We will also demonstrate how to run programs in BlueJ, the programming environment you will use in this course. In this video we will look at how code is organized is Java, and how programs are executed by the computer.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |