PeriodコンストラクタからDayクラスのインスタンスを2つ読み込み、それぞれの年月日を読み込み、fromの方がtoよりも昔ならばfromとtoのインスタンスを入れ替えるクラスPeriodを作成したいのですが、どうも、if分を通り抜けてしまって、fromの方が昔でも反転しません。 改善策を教えていただけると幸いです。 以下、コードを記述します。 public class Period{ private static Day from; private static Day to; private static Day have;
Period(Day f, Day f){ from = f; to = t; }
public static void main(String[ ] args){
if(to.getYear( ) < from.getYear( )){ Day have = new Day(from); Day from = to; Day to = have; } if(to.getYear( ) == from.getYear( )){ if(to.getMonth( ) < from.getMonth( )){ Day have = new Day(from); Day from = to; Day to = have; } } } }