-----------------------------------com.example.Clouds.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Clouds {
@SerializedName("all")
@Expose
public int all;
}
-----------------------------------com.example.Coord.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Coord {
@SerializedName("lon")
@Expose
public double lon;
@SerializedName("lat")
@Expose
public double lat;
}
-----------------------------------com.example.Example.java-----------------------------------
package com.example;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("coord")
@Expose
public Coord coord;
@SerializedName("weather")
@Expose
public List<Weather> weather = null;
@SerializedName("base")
@Expose
public String base;
@SerializedName("main")
@Expose
public Main main;
@SerializedName("visibility")
@Expose
public int visibility;
@SerializedName("wind")
@Expose
public Wind wind;
@SerializedName("clouds")
@Expose
public Clouds clouds;
@SerializedName("dt")
@Expose
public int dt;
@SerializedName("sys")
@Expose
public Sys sys;
@SerializedName("timezone")
@Expose
public int timezone;
@SerializedName("id")
@Expose
public int id;
@SerializedName("name")
@Expose
public String name;
@SerializedName("cod")
@Expose
public int cod;
}
-----------------------------------com.example.Main.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Main {
@SerializedName("temp")
@Expose
public double temp;
@SerializedName("feels_like")
@Expose
public double feelsLike;
@SerializedName("temp_min")
@Expose
public double tempMin;
@SerializedName("temp_max")
@Expose
public double tempMax;
@SerializedName("pressure")
@Expose
public int pressure;
@SerializedName("humidity")
@Expose
public int humidity;
}
-----------------------------------com.example.Sys.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Sys {
@SerializedName("type")
@Expose
public int type;
@SerializedName("id")
@Expose
public int id;
@SerializedName("country")
@Expose
public String country;
@SerializedName("sunrise")
@Expose
public int sunrise;
@SerializedName("sunset")
@Expose
public int sunset;
}
-----------------------------------com.example.Weather.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Weather {
@SerializedName("id")
@Expose
public int id;
@SerializedName("main")
@Expose
public String main;
@SerializedName("description")
@Expose
public String description;
@SerializedName("icon")
@Expose
public String icon;
}
-----------------------------------com.example.Wind.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Wind {
@SerializedName("speed")
@Expose
public int speed;
@SerializedName("deg")
@Expose
public int deg;
}
Почему иногда данные получаю а иногда нет, хотя код не меняю?
public class Main {
public static void main(String[] args) {
final double num1 = 10.14;
final double num2 = 11.142;
final double num3 = 13.1844;
final Double sum = (num1 + num2 + num3);
long result1 = Math.round(sum);
System.out.println(result1);
BigDecimal result2 = BigDecimal.valueOf(sum).setScale(0, RoundingMode.HALF_UP);
System.out.println(result2);
BigDecimal result3 = BigDecimal.valueOf(sum).round(new MathContext(2, RoundingMode.HALF_UP));
System.out.println(result3);
Long result4 = sum.longValue();
System.out.println(result4);
}
}
Create iOS Apps in Java
Port your existing Android App, or build a native Cross-Platform App from scratch
Please ask your host if they’re using “mod_secure” and if this error is a result of their rule set.
Hosting company has sorted it out by turning off the rate limiter!
// сигнатуры методов могут отличаться
takeBook(); // взять книгу
returnBook(); // вернуть книгу
orderBook(); // заказать книгу
bringBook(); // принести книгу
findBook(); // найти книгу
overdueNotification(User reader); // уведомить о времени возврата
Reader implements iReader
Librarian implements iLibrarian
Supplier implements iSupplier
Admin implements iAdministrator
Admin implements iAdministrator, iReader
имплементируем нужный интерфейс тоже.Reader extends User implements iReader
interface iReader<T extends User>
Reader extends User implements iReader<Reader>