This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DoubleToInt { | |
public static void main(String[] args) { | |
double numri1 = 12.3; | |
int numri2 = (int) numri1; | |
System.out.println(numri2); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntToDouble { | |
public static void main(String[] args) { | |
int numri1 = 123; | |
double numri2 = numri1; | |
System.out.println(numri2); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LongToInt { | |
public static void main(String[] args) { | |
long numri1 = 789; | |
int numri2 = (int) numri1; | |
System.out.println(numri2); | |
long numri3 = 7892345678L; | |
int numri4 = (int) numri3; | |
System.out.println(numri4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntToLong { | |
public static void main(String[] args) { | |
int numri1 = 123; | |
long numri2 = numri1; | |
System.out.println(numri2); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ObjectToString { | |
public static void main(String[] args) { | |
Klasa k = new Klasa(); | |
String s1 = k.toString(); | |
System.out.println(s1); | |
String s2 = String.valueOf(s1); | |
System.out.println(s2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringToObject { | |
public static void main(String[] args) { | |
String teksti = "Java"; | |
Object objekti = teksti; | |
System.out.println(objekti); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharToString { | |
public static void main(String[] args) { | |
char shkronje = 'A'; | |
String tekst = String.valueOf(shkronje); | |
System.out.println(tekst); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class StringToChar { | |
public static void main(String[] args) { | |
String name = "Java"; | |
char k = name.charAt(0); | |
System.out.println(k); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.DateFormat; | |
import java.text.SimpleDateFormat; | |
import java.util.Calendar; | |
import java.util.Date; | |
public class DateToString { | |
public static void main(String[] args){ | |
Date d1 = Calendar.getInstance().getTime(); | |
DateFormat formati = new SimpleDateFormat("dd.MM.yyyy hh:mm:ss"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
public class StringToDate { | |
public static void main(String[] args) throws Exception { | |
String d1 = "28/02/2021"; | |
System.out.println(d1); | |
Date d2 = new SimpleDateFormat("dd.MM.yyyy").parse(d1); |