首页 \ 问答 \ 在Java中使用HashTable的问题(Issues with using HashTable in Java)

在Java中使用HashTable的问题(Issues with using HashTable in Java)

我正在尝试使用哈希表,当我试图搜索一个对象时,我没有看到该对象,但是如果我打印它我就能看到它。

节点类:

public class Node {

    int x;
    int y;


    public Node() {

        this.x=0;
        this.y=0;

    }

    public Node(int x,int y) {
        this.x=x;
        this.y=y;
    }



    public String toString(){

        return "(Node: x,y="+Integer.toString(x)+","+Integer.toString(y)+")";

    }

}

主类:

public class GridWalk {


    static Hashtable <Node, Integer> myMap;
    static Stack<Node> nodes;

    public static void main(String[] args) {

        myMap = new Hashtable<Node,Integer>();
        nodes=new Stack<Node>();

        Node start=new Node(0,0);

        Node new1= new Node(100,100);
        myMap.put(new1,new Integer(1));
        Node new2=new Node (100,100);
        System.out.println("Already there ? huh: "+new2.toString()+" at "+myMap.get(new2)); 

    }
}

我在打印行时得到NULL。 知道为什么吗?


I am trying to use hashtable and when trying to search for an object,I do not see the object, but I can see it if I print it.

Node Class:

public class Node {

    int x;
    int y;


    public Node() {

        this.x=0;
        this.y=0;

    }

    public Node(int x,int y) {
        this.x=x;
        this.y=y;
    }



    public String toString(){

        return "(Node: x,y="+Integer.toString(x)+","+Integer.toString(y)+")";

    }

}

Main Class:

public class GridWalk {


    static Hashtable <Node, Integer> myMap;
    static Stack<Node> nodes;

    public static void main(String[] args) {

        myMap = new Hashtable<Node,Integer>();
        nodes=new Stack<Node>();

        Node start=new Node(0,0);

        Node new1= new Node(100,100);
        myMap.put(new1,new Integer(1));
        Node new2=new Node (100,100);
        System.out.println("Already there ? huh: "+new2.toString()+" at "+myMap.get(new2)); 

    }
}

I am getting NULL when I do the print line. Any idea why ?


原文:https://stackoverflow.com/questions/9651641
更新时间:2023-12-22 16:12

最满意答案

HTML表单标记具有method属性。 此属性定义是使用POST还是GET发送内容。

检查<form method=?>

阅读: http//www.w3schools.com/html/html_forms.asp


HTML Form tag has a method attribute. This attribute defines whether the content will be sent using POST or GET.

Check the method of the <form method=?>.

Read: http://www.w3schools.com/html/html_forms.asp

相关问答

更多
  • HTML表单标记具有method属性。 此属性定义是使用POST还是GET发送内容。 检查
    。 阅读: http : //www.w3schools.com/html/html_forms.asp HTML Form tag has a method attribute. This attribute defines whether the content will be sent using POST or GET. Check the method of the
  • 要获得更多RESTfull,您应该发送POST http://api.example.com/conent/content_id/tags因为POST http://api.example.com/conent/content_id/tags/tag_id表示更新现有资源。 但是如果你想以这种方式做到这一点,你可以指定集合的url : var Content = Backbone.Model.extend({ urlRoot: '/content' }); var Tag = Backbone.Mod ...
  • 您应该添加更多代码。 无论如何,它看起来不像真正惯用的redux。 如果你正在进行Ajax调用,你应该有一个中间件,比如redux-thunk。 它将在Ajax回调中调度一个动作。 该操作将包含服务器响应并由reducer处理。 你将获得一个带有id的新状态,因此新的组件渲染将在道具中获得它。 更新: 由于您使用的是redux-saga中间件,因此您只需在saga Ajax回调中执行对react-router-redux操作创建器的调用。 Doc在这里: https : //github.com/react ...
  • 您可以使用参数哈希发送所有必需的参数。 所以,构建一个params哈希,然后将其传递给post调用,如下所示: let(:params) { { candidate: FactoryGirl.attributes_for(:candidate), id: position.id } } post :candidate, params You can send all the required params in a params hash. So, build a params hash and then ...
  • 使用request.POST.getlist('category_id') https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.QueryDict.getlist Use request.POST.getlist('category_id') https://docs.djangoproject.com/en/1.9/ref/request-response/#django.http.QueryDict.getlis ...
  • 不是直接的,Velocity本身只是一种微小的模板语言,适用于您在上下文中放置的任何对象。 纯Velocity没有这样的对象,程序的其他部分必须填充上下文。 如果您正在使用Velocity作为您正在编写的程序的一部分,那么您可以填充自己的上下文,请参阅此简介 ,其中介绍了如何创建上下文并在呈现模板时使用它。 您可以使用一个或多个默认工具 ,尤其是VelocityView工具 ,它将提供对请求和响应的访问。 大多数使用Velocity的“应用程序”(例如XWiki)都使用自己的机制提供对请求和响应的访问。 查 ...
  • 好的,任何人都有同样的问题,我将发布解决方案。 因此@findall指出我正确的编码不是JSON,它只是一个url编码。 但在我将其更改为url编码后,它仍然无法正常工作。 所以我给了AlamoFire一个镜头,它完全奏效了! 这是代码: var headers: NSDictionary = ["X-Mashape-Key": "Hm5NokCvUamshPFfnQCRJKne3UuCp1Cq48FjsnMnQnEcHN0gk6", "Content-Type": "application/x-www-f ...
  • 有一些事情正在发生,但首先您应该了解utf8信息是由Rails表单助手生成的。 如果你真的不想要它,建立你自己的而不是使用表单助手。 接下来,由于用户表面上提供了barcodeform ,因此它不应该是表单操作的一部分。 你可以通过一些javascript来完成类似的事情,但这不是最好的做法。 您希望将barcodeform值作为查询参数,以便可以使用params[:barcodeform]在控制器中访问它,并以适当的方式处理用户输入的任何疯狂。 最后,您需要修复路线。 您的路线当前正在生成如下 ...
  • 如果您正在从节点页面本身执行帖子,则可以使用 $nid = arg(1); arg()将检索传入的drupal路径的值.IE: http://example.com/hi/mark/it/is/erik arg(0) = hi arg(1) = mark arg(2) = it ... 因为每个节点页面的URL都是http://example.com/node/ $ nid,所以即使节点有别名,arg(1)也会始终返回正确的nid。 编辑 : 使用preprocess_node()并添加对drupal_ ...
  • 首先,除非只有一个事件可以关联到给定的货币,否则您的映射是错误的:事件和货币之间的关联应该是ManyToOne,而不是OneToOne:许多事件共享同一货币。 现在你的问题。 保存事件时,您将从浏览器接收一些包含事件信息的JSON对象,包括事件所引用的货币的ID。 因此,您需要做的就是获取由此标识标识的Currency实例,然后创建并保留包含该货币的Event实例: Currency currnecy = em.find(Currency.class, currencyId); // or, if you ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。