如何作为bean访问一个简单的java对象?
例如:
class Simple {
private String foo;
String getFoo() {
return foo;
}
private void setFoo( String foo ) {
this.foo = foo;
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想像这样使用这个对象:
Simple simple = new Simple();
simple.setFoo( "hello" );
checkSettings( simple );
Run Code Online (Sandbox Code Playgroud)
所以我正在寻找该方法的实现checkSettings( Object obj ):
public boolean checkSettings( Object obj ) {
// pseudocode here
Bean bean = new Bean( obj );
if( "hello".equals( bean.getAttribute( "foo" ) ) {
return true;
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
java语言包含一个叫做java.beans听起来可以帮助我的软件包.但我找不到一个好的起点.
任何提示?
#include<stdio.h>
int main()
{
char a='x';
printf("%c %d",a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
x 134513696
什么是134513696?
为什么使用全局变量是个坏主意?
我想为所有要使用的类创建一个可用的变量数组.它将存储关键状态,因此不能将其设置为const(final).
你能告诉我一些其他(正确的)如何做到这一点的方法吗?
我想在我的Windows应用商店应用中更改AppBar按钮的图标.
我发现AppBar按钮的XAML标记如下所示:
<Style x:Key="PicturesAppBarButtonStyle"
TargetType="ButtonBase"
BasedOn="{StaticResource AppBarButtonStyle}">
<Setter Property="AutomationProperties.AutomationId"
Value="PicturesAppBarButton"/>
<Setter Property="AutomationProperties.Name"
Value="Pictures"/>
<Setter Property="Content" Value=""/>
</Style>
Run Code Online (Sandbox Code Playgroud)
内容值是什么意思?是否有任何内置图标的参考?
另外我如何显示自己的不同图标?
我试图在Java中使用printf截断到第三个小数点,但我一直只到第二个小数点.这是我试图这样做的代码行:
System.out.printf("The speed in ft/sec is %6.2f\n", time);
Run Code Online (Sandbox Code Playgroud) 我写的时候:
System.out.println("Give grade: ", args[0]);
Run Code Online (Sandbox Code Playgroud)
它给出了错误:
PrintStream类型中的方法println(String)不适用于参数(String,String).
为什么会这样?但是,当我试着写
System.out.println("Give grade :");
System.out.println(args[0]);
Run Code Online (Sandbox Code Playgroud)
没有错误显示.有没有办法可以在上面写一行println()?
尝试传递生成的序列(可能是更复杂的 struct 或 func 值),例如在数组初始化期间生成一些键字符串。
这是一个数组初始化字符串:
let MyArray: Array<Int> = Array<Int>(count: 100, repeatedValue:(for i in 0...99))
// it does not work, I am doing it wrong :(
// instead of (for i in 0...99) could be anything, a key sequence generator
Run Code Online (Sandbox Code Playgroud)
以下是文档中的内容:
/// Construct a Array of `count` elements, each initialized to
/// `repeatedValue`.
init(count: Int, repeatedValue: T)
Run Code Online (Sandbox Code Playgroud)
用生成或排序的值替换“T”的正确方法是什么。或者我不应该为此烦恼并让数组成为一个变量,然后再填充它?
谢谢。
.container {
border: 4px solid;
}
Run Code Online (Sandbox Code Playgroud)
和另一堂课
.border-red {
border-color:red;
}
Run Code Online (Sandbox Code Playgroud)
和我的HTML
<div class="container border-red"> </div>
Run Code Online (Sandbox Code Playgroud)
边框颜色不适用于元素,除非我.border-red之前放过该类
.container
请检查演示JSFIddle
我正在尝试构建一个程序,它接受一个整数数组作为参数并返回一个String.如果数组从最小到最大排序,字符串将是"升序",如果数组从最大到最小排序,则"降序","未排序"是数组根本没有排序和"所有相同的"如果数组的所有元素都相等.
到目前为止,我有以下代码.我是在正确的轨道上吗?我一直在下面指出的行上出现错误,说"参数类型的运算符>未定义".知道是什么原因引起的吗?
import java.util.*;
import java.io.*;
import java.util.Scanner;
public class arrayCheck {
public static void main(String[] args) throws IOException {
arrayInput();
isSorted(null);
}
public static String arrayInput() {
int size = 0;
Scanner in = new Scanner(System.in);
System.out.println("Enter the size of the array: ");
size = in.nextInt();
System.out.println("The size you enetered is " + size);
int[] array = new int[size];
System.out.println("Enter the array: ");
int j = 0;
while (j < size) {
System.out.print("Enter int"+ (j + 1) + ": …Run Code Online (Sandbox Code Playgroud)