我的第一篇java初学代码
来源:互联网 发布:java url encode 编辑:程序博客网 时间:2024/05/22 08:24
class link{
private node1 root;
private int count = 0;
private int foot =0;
private class node1{
private String data;
private node1 next;
public node1(String data){
this.data=data;
}
public void addnode(node1 newnode){
if (this.next == null){
this.next = newnode;
}
else {
this.next.addnode(newnode);
}
}
public void setnode(int index,String data){
if (link.this.foot ++ == index){
this.data = data;
}
else {
this.next.setnode(index,data);
}
}
public void printnode(){
System.out.println(this.data);
if (this.next != null){
this.next.printnode();
}
}
public String getnode(int index){
if (link.this.foot ++ == index){
return this.data;
}
else {
return this.next.getnode(index);
}
}
}
public void set(int index , String data){
if (index > this.count -1){
return ;
}
this.foot = 0;
this.root.setnode(index ,data);
}
public void add(String data){
node1 newnode = new node1(data);
if (this.root == null ){
this.root = newnode;
}
else {
this.root.addnode(newnode);
}
this.count ++;
}
public void print(){
if (this.root != null){
this.root.printnode();
}
}
public String get(int index){
if (index > this.count -1){
return null;
}
this.foot = 0;
return this.root.getnode(index);
}
}
public class node{
public static void main(String args[]){
link lk = new link();
lk.add("Hello");
lk.add("World");
lk.print();
lk.set(0,"Mr");
lk.set(1,"Hello");
System.out.println("===============");
System.out.println(lk.get(0));
System.out.println(lk.get(1));
System.out.println("===============");
}
}
private node1 root;
private int count = 0;
private int foot =0;
private class node1{
private String data;
private node1 next;
public node1(String data){
this.data=data;
}
public void addnode(node1 newnode){
if (this.next == null){
this.next = newnode;
}
else {
this.next.addnode(newnode);
}
}
public void setnode(int index,String data){
if (link.this.foot ++ == index){
this.data = data;
}
else {
this.next.setnode(index,data);
}
}
public void printnode(){
System.out.println(this.data);
if (this.next != null){
this.next.printnode();
}
}
public String getnode(int index){
if (link.this.foot ++ == index){
return this.data;
}
else {
return this.next.getnode(index);
}
}
}
public void set(int index , String data){
if (index > this.count -1){
return ;
}
this.foot = 0;
this.root.setnode(index ,data);
}
public void add(String data){
node1 newnode = new node1(data);
if (this.root == null ){
this.root = newnode;
}
else {
this.root.addnode(newnode);
}
this.count ++;
}
public void print(){
if (this.root != null){
this.root.printnode();
}
}
public String get(int index){
if (index > this.count -1){
return null;
}
this.foot = 0;
return this.root.getnode(index);
}
}
public class node{
public static void main(String args[]){
link lk = new link();
lk.add("Hello");
lk.add("World");
lk.print();
lk.set(0,"Mr");
lk.set(1,"Hello");
System.out.println("===============");
System.out.println(lk.get(0));
System.out.println(lk.get(1));
System.out.println("===============");
}
}
阅读全文
0 0
- 我的第一篇java初学代码
- 初学Java--第一篇
- 初学Java者的第一篇
- 初学java线程同步容易出错的地方(我的第一篇博客)
- 我的第一篇html代码
- 入行IT类的第一篇...初学Java感想
- 第一篇:初学Java接触到的循环练习题
- java程序猿我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- 我的第一篇
- Sublime Text 3中文乱码并配置Java编译环境
- win10
- ASP.NET MVC 认识
- 【BZOJ2301】[HAOI2011]Problem b
- 每天一个java小程序之冒泡排序
- 我的第一篇java初学代码
- deeplearning.ai之神经网络和深度学习
- 自动生成 Makefile 尝试
- 程序设计与算法(一)C语言程序设计CAP 第四周
- 【考研】第十六周总结
- jq实现批量上传+裁剪功能
- 初学Android
- 机房总结二
- [黑科技]__gnu_cxx::rope STL中的可持久化数组