java代码加运行图 简单java代码及运行过程

安卓在java代码中怎么添加imageView图片1、创建imageview对象
2、设置imageview的图片
3、添加到布局中
示例代码
ViewGroup group = (ViewGroup) findViewById(R.id.viewGroup); //获取原来的布局容器
ImageView imageView = new ImageView(this);//创建imageview
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));//image的布局方式
imageView.setImageResource(R.drawable.ic_launcher);//设置imageview呈现的图片
group.addView(imageView);//添加到布局容器中,显示图片 。
http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/SWTStyledText.htm 下有个SWT的StyledText例子package swt_jface.demo4;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
public class WrapLines {
Display display = new Display();
Shell shell = new Shell(display);
Text text1;
Text text2;
String line = "abcdefghijklmnopqrstuvwxyz0123456789";
private void init() {
text1 = new Text(shell, SWT.BORDER | SWT.MULTI);
//text.setTextLimit(12);
text1.setText(line);
text2 = new Text(shell, SWT.BORDER | SWT.WRAP);
text2.setText(line);
}
public WrapLines() {
shell.setLayout(new GridLayout(2, true));
(new Label(shell, SWT.NULL)).setText("SWT.BORDER |\nSWT.MUTLI");
(new Label(shell, SWT.NULL)).setText("SWT.BORDER |\nSWT.WRAP");
init();
GridData gridData = https://www.04ip.com/post/new GridData(GridData.FILL_BOTH);
text1.setLayoutData(gridData);
gridData = https://www.04ip.com/post/new GridData(GridData.FILL_BOTH);
text2.setLayoutData(gridData);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new WrapLines();
}
}
Java斐波那契数第35个数,流程图加代码?流程图如下:
public int Fibonacci(int n) {
int[] res = {0, 1};
if(n2) {
return res[n];
}
int first = 0;
int second = 1;
int fibn = 0;
for(int i = 2; i = n; i++) {
fibn = first + second;
first = second;
second = fibn;
}
return fibn;
}
public static void main(String[] args) {
System.out.println(Fibonacci(35));
}
Java 习题//Shape抽象类
package A;
public abstract class Shape {
String name;
public abstract double GetArea();
public abstract double GetLength();
}
//Test类(包括最终类)
package A;
import java.io.*;
class Circle extends Shape{
int radius;
Circle(int ridius){
this.radius = ridius;
}
public double GetArea(){
return Math.PI*Math.pow(radius, 2);
}
public double GetLength(){
return 2*Math.PI*radius;
}
}
class Rectangle extends Shape{
int width, length;
public Rectangle(int width, int length) {
this.width = width;
this.length = length;
}
public double GetArea(){
return width*length;
}
public double GetLength(){
return 2*(width+length);
}
}
public class Test {
public static void main(String[] args) throws IOException{
BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));
System.out.println("Input radius for Cricle: ");
String radius = stdin.readLine();
Circle c = new Circle(Integer.parseInt(radius));
System.out.println("Area: "+c.GetArea()+", Length: "+c.GetLength());
System.out.println("Input width for Rectangle: ");

推荐阅读