java实训代码怎么讲 java实战教程

java代码解读

第一个if是判断searchkey是不是空的,如果不是空的,就追加到name字段作为查询条件,like模糊查询

站在用户的角度思考问题,与客户深入沟通,找到芜湖县网站设计与芜湖县网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站建设、成都网站建设、企业官网、英文网站、手机端网站、网站推广、域名注册、网络空间、企业邮箱。业务覆盖芜湖县地区。

接着第二个if判断如果status的值不为空,就追加到status作为条件

如果status为空,走else分支,从userContext中获取到employee对象,接着判断,如果它的角色不是manager的话

把这个对象的id拿出来,作为seller.Id的条件进行查询

这是我们的java实训内容,有没有大神知道其中的代码怎么打?知道几条也行,谢谢了! 2、 能新

2,3已经实现,其他的自己试着做一下不难

package com.ui;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.IOException;

class NoteBook{

//创建文件

public File creatFile(String path,String name){

File tempPath=new File(path);

File tempFile=new File(path+File.separator+name+".txt");

if(!tempPath.exists()){

tempPath.mkdirs();

try {

tempFile.createNewFile();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}else{

try {

tempFile.createNewFile();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

return tempFile;

}

//写入文件

public void writeFile(File file,String content){

try {

FileOutputStream fos=new FileOutputStream(file);

fos.write(content.getBytes());

fos.close();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

//读取文件

public String readFile(File file){

String str="";

try {

FileInputStream fis=new FileInputStream(file);

int datas;

while((datas=fis.read())!=-1){

str+=String.valueOf((char)datas);

}

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

return str;

}

//复制文件

public  void copyFile(File f1,File f2){

if(!f1.exists()){

System.out.println("目录"+f1.getName()+"不存在");

}else{

File[] files=f1.listFiles();

for(File f:files){

if(f.isDirectory()){

File temp=new File(f2,f.getName());

temp.mkdirs();

copyFile(f, temp);

}else{

File temp=new File(f2,f.getName());

try {

temp.createNewFile();

FileOutputStream fos=new FileOutputStream(temp);

FileInputStream fis=new FileInputStream(f);

int datas;

while((datas=fis.read())!=-1){

fos.write(datas);

}

fos.close();

fis.close();

} catch (FileNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

}

//剪贴文件

public void cutFile(File f1,File f2){

int i=0;

if(!f1.exists()){

System.out.println("目录"+f1.getName()+"不存在");

}else{

i++;

File[] files=f1.listFiles();

for(File f:files){

if(f.isDirectory()){

File temp=new File(f2,f.getName());

temp.mkdirs();

cutFile(f, temp);

}else{

File temp=new File(f2,f.getName());

try {

temp.createNewFile();

FileOutputStream fos=new FileOutputStream(temp);

FileInputStream fis=new FileInputStream(f);

int datas;

while((datas=fis.read())!=-1){

fos.write(datas);

}

fis.close();

fos.close();

f.delete();

} catch (FileNotFoundException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

}

f1.delete();

}

}

Java实验,代码怎么写?

Shape.java接口代码

public interface Shape {

public static final double PI = 3.14d;

public double area();

}

Circle.java圆类代码

public class Circle implements Shape {

private double radius;

public Circle(double radius) {

  this.radius = radius;

}

@Override

public double area() {

  return PI * this.radius * this.radius;

}

public double perimeter() {

  return 2 * PI * this.radius;

}

}

Cylinder.java圆柱体类代码

public class Cylinder extends Circle {

private double height;

public Cylinder(double radius, double height) {

  super(radius);

  this.height = height;

}

public double area() {

  return 2 * super.area() + super.perimeter() * this.height;

}

public double volume() {

  return super.area() * this.height;

}

}

X5_3_6.java主类代码

public class X5_3_6 {

public static void main(String[] args) {

  Circle cir1 = new Circle(5);

  System.out.println("圆的面积为:" + cir1.area());

  System.out.println("圆的周长为:" + cir1.perimeter());

  Cylinder cy1 = new Cylinder(10, 15);

  System.out.println("圆柱体的表面积为:" + cy1.area());

  System.out.println("圆柱体的体积为:" + cy1.volume());

}

}

上面是我写的代码,下图是执行结果,麻烦看一下,是否可以。


当前文章:java实训代码怎么讲 java实战教程
网址分享:http://lszwz.com/article/hpeipe.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款