我正在努力实现这一目标.我有一串9char(总是一样的).但我也知道,第一个和最后一个字母总是一个aplhabetic,它一定是.中间的其余部分是数字.如何检查.到目前为止我得到了这个逻辑,语法是我的问题
string samplestring;
samplestring = a1234567B
If(samplestring.length() == 9 && samplestring.substring(0,1).uppercase && samplestring.substring(8,9) && samplestring.THE REST OF THE CHAR IN THE MIDDLE ARE DIGITS)
{
println("yes this is correct");
}
else
{
println("retype");
}
Run Code Online (Sandbox Code Playgroud)
请不要介意简单的英语只是想知道语法,但逻辑是我希望..
还可以告诉我那些小写的如何转换为大写?
我试图在数组中找到一个值,我确定这个值只存在一次,所以我试图找到该值并返回存储它的数组的索引,如果没有找到返回-1这是我想要做的:
static Integer[] accs = new Integer[20];
public static int search()
{
Integer[] numbers;
numbers = accs;
Integer key;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Account Number:");
key = sc.nextInt();
for (Integer index = 0; index < numbers.length; index++)
{
if ( numbers[index] == key )
return index; //We found it!!!
}
// If we get to the end of the loop, a value has not yet
// been returned. We did not find the key in this array. …Run Code Online (Sandbox Code Playgroud) 我试图检查一个字符串中是否存在一系列数字比这更优雅的方式?
if (ccnumeric.contains("51")
|| ccnumeric.contains("52")
|| ccnumeric.contains("53")
|| ccnumeric.contains("54")
|| ccnumeric.contains("55"))
Run Code Online (Sandbox Code Playgroud)
当我在字符串中检查int范围时,我想不出任何满足这个的方法.
我正在尝试创建一个下拉列表/组合框窗口小部件,并且很难计算。下面是我尝试过的代码。基本上创建了一个列表,该列表是我从这里到那里收集的,但是无法将其相应地放入我自己的代码中。
import 'package:flutter/material.dart';
class Signup extends StatefulWidget{
Signup({Key key}) : super (key:key);
final String title;
@override
SignupPage createState() => new SignupPage();
}
class SignupPage extends State<Signup> {
@override
Widget build(BuildContext context) {
List _countrycodes = ["+65","+91"];
List<DropdownMenuItem<String>> _dropDownMenuItems;
String _selectedCountryCode;
List<String> _colors = <String>['', 'red', 'green', 'blue', 'orange'];
String _color = '';
List<DropdownMenuItem<String>> getDropDownMenuItems() {
List<DropdownMenuItem<String>> items = new List();
for (String code in _countrycodes) {
items.add(new DropdownMenuItem(
value: code,
child: new Text(code)
));
}
return items;
}
/**return new …Run Code Online (Sandbox Code Playgroud)