首页 \ 问答 \ 在java中传递空参数(被解析为没有得到任何agrument al all)(Pass empty argument in java (to be parsed as not getting any agrument al all))

在java中传递空参数(被解析为没有得到任何agrument al all)(Pass empty argument in java (to be parsed as not getting any agrument al all))

我想知道在java中是否有任何方法将参数传递给java实际读取的方法,因为根本没有得到任何参数。 更具体:我有一个方法的两个版本,一个需要一个参数,另一个根本没有。 因此,在没有参数的情况下调用该方法时,将执行第二个版本。 有没有办法实际传递一个空读参数,其中java读取根本没有提供参数?

void exampleMethod(){
    // do stuff
}

void exampleMethod(arg){
    // do other stuff
}

我想能打电话

exampleMethod(?);

这样就调用了该方法的第一个版本。


I was wondering if there is any way in java to pass an argument to a method which is actually read by java as not getting any argument at all. More concrete: I have got two versions of a method, one requiring one argument and the other none at all. So when the method is called without an argument the second version is executed. Is there a way to actually pass an empty argument which java reads as not being provided with an argument at all?

void exampleMethod(){
    // do stuff
}

void exampleMethod(arg){
    // do other stuff
}

I would like to be able to call

exampleMethod(?);

So that the first version of the method is called.


原文:https://stackoverflow.com/questions/28384201
更新时间:2022-02-19 06:02

最满意答案

发现问题:

包装节点未正确关闭。

<div att1="value" att2="value"
  <div id="header-text">...</div>
</div>

AFAIK,FF和IE礼貌地修复了标签......但是Opera没有,因此孩子DIV实际上不是DOM中的元素。


应该工作正常。 id为“header-text”的元素是什么? 您确定只有一个匹配项,并且它具有可编辑的内容吗?

你可以发布一些标记,以便我们测试吗?

从PPK的网站,似乎没有任何Opera问题: http//www.quirksmode.org/dom/innerhtml.html

更新:在XP上的Opera 9.6.4中运行此代码对我来说很好。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>innerHTML test</title>
<script>
  function doIt(){
    document.getElementById("header-text").innerHTML = "something interesting";
  }
</script>
</head>
<body>
  <div id="header-text" class="picture-text">
    Static text
  </div>
  <input type="button" value="Change It" onclick="doIt();"/><br/>
</body>
</html>

FOUND THE ISSUE:

The wrapping node was not properly closed.

<div att1="value" att2="value"
  <div id="header-text">...</div>
</div>

AFAIK, FF and IE were politely fixing the tag... but Opera wasn't, thus the child DIV wasn't really an element in the DOM.


Should work fine. What is the element with the id "header-text"? Are you sure there is only one match, and it has editable content?

Can you post some of the markup so we can test?

From PPK's site, there doesn't seem to be any Opera issues: http://www.quirksmode.org/dom/innerhtml.html

Update: Running this code in Opera 9.6.4 on XP works fine for me.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>innerHTML test</title>
<script>
  function doIt(){
    document.getElementById("header-text").innerHTML = "something interesting";
  }
</script>
</head>
<body>
  <div id="header-text" class="picture-text">
    Static text
  </div>
  <input type="button" value="Change It" onclick="doIt();"/><br/>
</body>
</html>

相关问答

更多
  • 发现问题: 包装节点未正确关闭。
    ...
    AFAIK,FF和IE礼貌地修复了标签......但是Opera没有,因此孩子DIV实际上不是DOM中的元素。 应该工作正常。 id为“header-text”的元素是什么? 您确定只有一个匹配项,并且它具有可编辑的内容吗? 你可以发布一些标记,以便我们测试吗? 从PPK的网站,似乎没有任何Opera问题: http : //ww ...
  • Opera的市场份额太小,无法专门为它设计,但是这个页面有一个应该可行的解决方案,但是当你调整大小时它不能用于Opera。 http://www.electrictoolbox.com/html-css-footer/ 您可能想要查看作者的作用,看看您是否能够理解您的不同之处。 Opera has too small a market share for me to design specifically for it, but this page has a solution that should wo ...
  • 如果您不遵循W3C标记建议,则会发生此错误。 IE对此非常挑剔而Firefox并非如此。 你可以在这里阅读更多内容: http : //blog.rakeshpai.me/2007/02/ies-unknown-runtime-error-when-using.html 这是一个类似的问题可能对您有所帮助: 修复IE8中的“未知运行时错误” 这是关于同一事物的另一个链接,特别是“表单中的表单”问题: http : //jadendreamer.wordpress.com/2009/06/02/interne ...
  • 你需要做两件事: 1)您的jsTree函数需要在您的数据由ajax加载后再次运行: xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("treeviewer").innerHTML = this.responseText; $("#treeviewer").jstree({ ...
  • 问题是您没有doctype,因此您的页面使用的是Quirks模式 。 将其添加为第一行: 这修复了Opera中的菜单,并大大改进了Internet Explorer中的整个页面。 始终将doctype添加到新站点,没有例外。 The problem is that you don't have a doctype, so your page is using Quirks Mode. Add this as the very first line:
  • 获得.innerHTML时,关闭标签会在Firefox中显示出来。 我建议丢失的标签是由于你的标记,我很确定无效:
    text:  
    元素的父元素 ...
  • 我真的不知道,但也许它与此有关。 http://www.opera.com/support/kb/view/827/ 歌剧疯狂的快速后退按钮必须做些什么。 我注意到它们发布10.5后感觉有点不同(有些页面感觉速度较慢,也许他们调整了它),所以也许这就是为什么有些人在这里说他们不能重现内存泄漏。 I really don't know, but maybe it's related to this. http://www.opera.com/support/kb/view/827/ Opera's crazy ...
  • 好吧,它变得容易 h1.innerHTML = wordlist[i]; 为了你所追求的,即: h1.innerHTML = ""+wordlist[i]+""; 要在新选项卡中打开它,您必须添加属性“target”并将其赋值为空白。 我认为它在HTML 5中被弃用了但是...... Well its as easy as chan ...
  • 这里是: .newsletter i { display:block; text-align: center; line-height:35px; height: 35px; width: 35px; color: #FFFFFF; font-size: 18px; background-color: #00495e; border-radius: 100%; border: 1px solid #FFFFFF; padding: 7px; transitio ...
  • 这是如何定义Opera动画关键帧 @-o-keyframes rotate-l { 0% { -o-transform: rotateZ(0deg);} 100% { -o-transform: rotateZ(360deg); } } 为了最佳实践和性能 .big, .small{ -webkit-backface-visibility:hidden; /* Chrome and Safari */ ...
  • 相关文章

    更多

    最新问答

    更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)