“casting explicite” Réponses codées

casting explicite

// Explicit casting is manually casting a variable to another type

double x = 1.1;
int y = x + 2; // This won't work, because x is a double and y an integer.

// So instead do it like this:
double x = 1.1;
int y = (int)x + 2;
Jesse Swart

Coulage de conversion explicite

short a=2000;
int b;
b = (int) a;    // c-like cast notation
b = int (a);    // functional notation
Rich Rattlesnake

Qu'est-ce que le casting explicite

/*
Type Casting Types in Java
   Java Type Casting is classified into two types.
       - Widening Casting (Implicit) – Automatic Type Conversion
       - Narrowing Casting (Explicit) – Need Explicit Conversion
       
source: https://www.tutorialspoint.com/what-are-the-differences-between-widening-casting-implicit-and-narrowing-casting-explicit-in-java
*/
HmongsterMoua

Réponses similaires à “casting explicite”

Questions similaires à “casting explicite”

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code