什么是Convert.ChangeType的Java等效项 [英] What is a java equivalent for Convert.ChangeType

查看:248
本文介绍了什么是Convert.ChangeType的Java等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要java等效于c#的Convert.ChangeType吗?

有人可以帮助我吗?

Hi , I need java equivalent for Convert.ChangeType at c# ?

Can anybody help me ?

推荐答案

据我所知,这没有直接对等的地方.

java.lang中的大多数(如果不是全部)基本数据类型提供安全地转换的静态方法,例如,将字符串转换为可以使用的数字:
To the best of my knowledge, there is no direct equivilent to this.

Most (if not all) of the basic data types in java.lang provide static methods to safely convert, for example to convert a string to a number you can use:
int i = Integer.getInteger("546");



阅读 API [



Read the API[^] for more details.

[ps don''t answer your own questions, just amend the original.]


如果要在Java中将String转换为Int,请使用:
字符串str ="120";
int num = Integer.parseInt(str);
If you want to convert String to Int in java use:
String str = "120";
int num = Integer.parseInt(str);




Convert.ChangeType在C#中可用.

通过以下链接.

http://msdn.microsoft.com/en-us/library /system.convert.changetype(VS.80).aspx

希望对您有帮助

问候
kumaran
Hi,

The Convert.ChangeType is available in C#.

go through the folloing link.

http://msdn.microsoft.com/en-us/library/system.convert.changetype(VS.80).aspx

hope this helps

regards
kumaran


这篇关于什么是Convert.ChangeType的Java等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆