a=10.00;
b=11.00;
mor_names=new String[]{};
for(double cal=Double.parseDouble(a);cal<=Double.parseDouble(b);) {
mor_names[val]=(Double.toString(cal));
System.out.println("values are:" + mor_names[val]);
val++;
cal=cal+0.15;
}
I try to add a value to string array but it raises a null pointer exception, why?
EDIT 1:
DateFormat time = new SimpleDateFormat("HH:mm");
try
{
timefrom =(Time) time.parse(json.get(position).toString());
timeto = (Time) time.parse(json.get(position).toString());
}
catch (ParseException e)
{
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
System.out.println("times are :"+timefrom+" "+timeto+" "+position);//null null 0 was output for this
for(Time i=timefrom;i.equals(timeto);)
{
cal.setTime(i);
System.out.println("values are:" + i);
mor_names[val]=(String) i.toString();
cal.add(Calendar.MINUTE, 15);
System.out.println("values are:" + mor_names[val]);
String newTime = df.format(cal.getTime());
try
{
i=new java.sql.Time(time.parse(newTime).getTime());
}
catch (ParseException e)
{
e.printStackTrace();
}
val++;
}
I tried to get a date in particular time gap so I am trying to sink with java calendar and manipulate my code but possibly I cant get it right.