Skip to content

Draft/assignment submission #209

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
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
.idea
**/*.iml
**/target
.DS_Store
0-0-intro/
1-0-java-basics/1-5-0-hello-annotations/
2-0-data-structures-and-algorithms/
3-0-java-core/3-6-1-file-reader/
3-0-java-core/3-6-2-file-stats/
3-0-java-core/3-6-3-crazy-regex/
4-0-object-oriented-programming/
6-0-test-driven-development/
29 changes: 0 additions & 29 deletions 0-0-intro/README.md

This file was deleted.

22 changes: 0 additions & 22 deletions 0-0-intro/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
* <p>
* todo: refactor this class so it uses generic type "T" and run {@link com.bobocode.basics.BoxTest} to verify it
*/
public class Box {
private Object value;
public class Box<T> {
private T value;

public Box(Object value) {
public Box(T value) {
this.value = value;
}

public Object getValue() {
public T getValue() {
return value;
}

public void setValue(Object value) {
public void setValue(T value) {
this.value = value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
*/
public class BoxDemoApp {
public static void main(String[] args) {
Box intBox = new Box(123);
Box intBox2 = new Box(321);
Box<Integer> intBox = new Box(123);
Box<Integer> intBox2 = new Box(321);
System.out.println((int) intBox.getValue() + (int) intBox2.getValue());

intBox.setValue(222);
// must not compile!!
intBox.setValue("abc"); // this should not be allowed
// the following code will compile, but will throw runtime exception
System.out.println((int) intBox.getValue() + (int) intBox2.getValue());
Expand Down
Loading