Skip to content
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

Added Java examples #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Chaakar
Copy link

@Chaakar Chaakar commented Jun 4, 2017

Added Java examples

Added Java examples
@GYFK GYFK requested a review from lidaamber June 6, 2017 21:54
Copy link

@lidaamber lidaamber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work. Just add a few changes, please.

private String city;
private int born;

public Objects() {}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO you should rename Objects to some more appropriate class name, Person, for example.

@@ -0,0 +1,45 @@
package com.company;

public class Objects {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd better rename this class to ObjectDemo and make your object itself a static class in your demo, or make it separate at all.

/**
* Created by Vova Moskalenko on 03.06.2017.
*/
public class ObjectAccess {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as about Object.


public ObjectAccess() {}

public String getCity() {return city;}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

Serialization person = new Serialization();
//serialization
try {
FileOutputStream fileOut =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File input and output are redundant here. You should display exactly serialization and deserialization in this example. For instance, you can use JSON serialization and deserialization as in JavaScript example.

person2 = (Serialization) in.readObject();
in.close();
fileIn.close();
}catch(IOException i) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

}catch(IOException i) {
i.printStackTrace();
return;
}catch(ClassNotFoundException c) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

out.close();
fileOut.close();
System.out.printf("Serialized data is saved in person.txt");
}catch(IOException i) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code style.

letters.add('C');
System.out.println(letters);

String[] arr = {"C++", "JavaScript", "Python", "Haskell", "Swift"};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why won't you make an arr a List<String> from the start?


String[] arr = {"C++", "JavaScript", "Python", "Haskell", "Swift"};
List<String> languages = Arrays.asList(arr);
System.out.print("length: " + languages.size() + " " + "languages[0]:" + " " + languages.get(0) + " "

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you split this line to fit 100 symbols in line, please? Just a code style suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants