?
-
If I have a class that has, among others, several fields such as
public class SomeClass {
private long startTime...
private long endTime...
// some other fields here
...
public SomeClass() {
}
public long getStartTime() {
return startTime;
}
...
}
is it a good idea if I do this:
public class SomeClass {
private TimeInfo timeInfo = new TimeInfo();
// some other fields here
...
public SomeClass() {
}
public TimeInfo getTimeInfo() {
return timeInfo;
}
protected static class TimeInfo {
private long startTime ...
private long endTime ...
...
public TimeInfo() {
}
public long getStart() {
return start;
}
...
}
}
This way, I can use 'getStart()' and 'getEnd()' rather than
'getStartTime()' and 'getEndTime()'.
Anything I should know of?
public class SomeClass {
private long startTime...
private long endTime...
// some other fields here
...
public SomeClass() {
}
public long getStartTime() {
return startTime;
}
...
}
is it a good idea if I do this:
public class SomeClass {
private TimeInfo timeInfo = new TimeInfo();
// some other fields here
...
public SomeClass() {
}
public TimeInfo getTimeInfo() {
return timeInfo;
}
protected static class TimeInfo {
private long startTime ...
private long endTime ...
...
public TimeInfo() {
}
public long getStart() {
return start;
}
...
}
}
This way, I can use 'getStart()' and 'getEnd()' rather than
'getStartTime()' and 'getEndTime()'.
Anything I should know of?