-
Notifications
You must be signed in to change notification settings - Fork 94
Finished derusting #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Lizock
wants to merge
7
commits into
auberonedu:main
Choose a base branch
from
Lizock:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9dce388
Completed NumberPractice
Lizock b9fef35
Finished ListPractice
Lizock 8c1efb1
Finished ArrayPractice
Lizock 931631e
Finished StringPractice
Lizock 3a681c9
Finished SetPractice
Lizock 5652aa0
Finished MapPractice
Lizock 5a10cdc
Finished Person
Lizock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,35 @@ | ||
| public class NumberPractice { | ||
| public static void main(String args[]) { | ||
| // Create a float with a negative value and assign it to a variable | ||
| float floatNum = -1.12f; | ||
|
|
||
| // Create an int with a positive value and assign it to a variable | ||
| int intNum = 9; | ||
|
|
||
| // Use the modulo % operator to find the remainder when the int is divided by 3 | ||
|
|
||
| int remainder = intNum % 3; | ||
|
|
||
| // Use the modulo % operator to determine whether the number is even | ||
| // (A number is even if it has a remainder of zero when divided by 2) | ||
| // Use an if-else to print "Even" if the number is even and "Odd" | ||
| // if the number is odd. | ||
| String evenOrOdd = ""; | ||
| if (intNum % 2 == 0){ | ||
| evenOrOdd = "Number is even"; | ||
| } else { | ||
| evenOrOdd = "Number is odd"; | ||
| } | ||
|
|
||
| // Divide the number by another number using integer division | ||
|
|
||
| /* | ||
| * Reminder! | ||
| * | ||
| * When dividing ints, the result is rounded down. | ||
| * Example: | ||
| * 7 / 3 = 2 when performing int division | ||
| */ | ||
| int divided = intNum / 2; | ||
|
|
||
| System.out.println(floatNum + ", " + intNum + ", " + remainder + ", " + evenOrOdd + ", " + divided ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,46 @@ | ||
| import java.util.*; | ||
| public class StringPractice { | ||
| public static void main(String[] args) { | ||
| // Create a string with at least 5 characters and assign it to a variable | ||
| String name = "eliza"; | ||
|
|
||
| // Find the length of the string | ||
| System.out.println(name.length()); | ||
|
|
||
| // Concatenate (add) two strings together and reassign the result | ||
| String name2 = "beth"; | ||
| name = name + name2; | ||
| System.out.println(name); | ||
|
|
||
| // Find the value of the character at index 3 | ||
| System.out.println(name.charAt(3)); | ||
|
|
||
| // Check whether the string contains a given substring (i.e. does the string have "abc" in it?) | ||
| System.out.println(name.contains("abc")); | ||
|
|
||
| // Iterate over the characters of the string, printing each one on a separate line | ||
| for(char letter : name.toCharArray()){ | ||
| System.out.println(letter); | ||
| } | ||
|
|
||
| // Create an ArrayList of Strings and assign it to a variable | ||
| ArrayList<String> lastName = new ArrayList<String>(); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to use interface types (List) |
||
|
|
||
| // Add multiple strings to the List (OK to do one-by-one) | ||
| lastName.add("Potter"); | ||
| lastName.add("Granger"); | ||
| lastName.add("Weasley"); | ||
| lastName.add("Malfoy"); | ||
|
|
||
| // Join all of the strings in the list together into a single string separated by commas | ||
| // Use a built-in method to achieve this instead of using a loop | ||
| //String words = String.join(", ", lastName); | ||
| String lastNameString = String.join(", ", lastName); | ||
| String words = "Potter, Granger, Weasley, Malfoy"; | ||
| System.out.println(lastNameString); | ||
|
|
||
| // Check whether two strings are equal | ||
| System.out.println(lastNameString.equals(words)); | ||
|
|
||
| /* | ||
| * Reminder! | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to use interface types (Set)