简体   繁体   English

Java中字符串到数组的转换

[英]Conversion of String into Array in Java

I am using some built in functions which is taking some arrays as input.我正在使用一些内置函数,这些函数将一些 arrays 作为输入。 Now I have value现在我有价值

String network=[{"GUID":"a","Type":"WiFi","WiFi":{"AutoConnect":true,"Passphrase":"12345678","SSID":"Free PTCL unlimited"}},{"GUID":"b","Type":"WiFi","WiFi":{"AutoConnect":true,"Passphrase":"12345678","SSID":"Free PTCL unlimited"}}]

Actually it is like an array but when i input this value the compiler say the function requires an array value.实际上它就像一个数组,但是当我输入这个值时,编译器说 function 需要一个数组值。 Now what i need to to convert this string into array现在我需要将此字符串转换为数组

your syntax in wrong...你的语法错误...

when you do String network=... you declare network as a String not as an array当您执行String network=...时,您将 network 声明为String而不是数组

arrays in java must be declared/initialized like: java 中的 arrays 必须像这样声明/初始化:

String[] network = {"a", "b", "c"};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM