In this Instructable, you will be creating a computer program written in the Java programming language. This Instructable will offer information on how to code in Java and will offer insight as to what strings and arrays are in Java. This program will demonstrate how to create a program that reads what you type into it as a string. After giving the program your input, it will ask for a number and tell you the character at that value in terms of an array.
To clarify more on the Java programming language; an array is basically a container that can hold a certain number of data. An array can only hold primitive data types, such as an integer or a single character. An integer is exactly what an integer is in mathematics, a positive or negative number, including 0. A character in Java is any single letter or symbol on the keyboard, such as an exclamation point ‘!’. From this explanation, a string in Java is an array of characters. So, a line of text could be considered a string. For example, “This is a string” would be a string in quotations, and would be an array of characters. To move through an array and access its data, we would select where in the array we want to access based on a numbering system. An array stores its values starting at 0 and counting up to the number of values stored in it minus 1. To continue my previous example, “This is a string” would have ‘T’ at its 0 position. It would also have ‘h’ at its 1 position, ‘i’ at its 2 position, and so on.
This Instructable is organized into warnings, equipment and materials required for the project, the steps necessary to complete the program, and the conclusion.
Warnings: Possible concerns regarding this project include: -the program crashing if the user enters a value outside of the range specified in step 25 -the program crashing if the user enters a value that is not an integer in step 25
Equipment/Materials: The equipment required for this project includes: a computer that is compatible with the Java Eclipse IDE, and Eclipse itself.
Add another line of space for code clarity.
Add another line of space for code clarity.
Add a final line of space for code clarity.
View the final output to make sure the position you entered is the character that is returned.
After creating this program, it is important to note that it will only continue to function as long as it is open, and only stays open until the user decides to close out of it manually. Otherwise, the program will close itself upon completion, and will not lead to any performance degradation of the computer as a result of this. As previously mentioned regarding running the program, make sure to only enter a value within the range specified by the program, or the program will crash and not function properly.