current position:Home>How does Java dynamically obtain what type of data is passed? It is used to judge whether the data is the same, dynamic data type

How does Java dynamically obtain what type of data is passed? It is used to judge whether the data is the same, dynamic data type

2022-01-27 06:06:12 CSDN Q & A

Problems encountered in writing an update logging tool class , How to dynamically obtain data types , To determine whether the data are the same , For example, passed a 1 What is stored in the database is 1.00 Now it's all converted to string comparison , So it's different It will be recorded , This situation should definitely not be recorded

img

Running results :

img

If the result is normal If the same data type For example, all of them are Double Words 1.00 and 1 It's the same It shouldn't be recorded , So I want to ask you Daniel , What can I do Data types can be obtained dynamically



Refer to the answer 1:

Use instanceof Statement to determine the data type , The use of reference :

if( Variable name  instanceOf  Type the name ( Class name )){....}



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270606099975.html