How do you specify a byte literal in Java?
2017-05-24 09:51
357 查看
问题: If I have a method
void f(byte b);
how can I call it with a numeric argument without casting?
f(0);gives an error.
答案:[/code]
You cannot. A basic numeric constant is considered an integer (or long if followed by a "L"), so you must explicitly downcast it to a byte to pass it as a parameter. As far as I know there is no shortcut.
f((byte)0);
查看原文:http://zccbbg.top/2017/05/24/specify-byte-literal-java/
相关文章推荐
- How do you calculate log base 2 in Java for integers?
- How do you remove the duplicate characters in a given string without using any additional buffer.
- JQuery怎么知道一个元素是否隐藏或显示How do you test if something is hidden in jQuery?
- ISE Simulator综合后仿真 - How do you run Post Synthesis Simulation in ISE Project Navigator?
- How do I instantiate a Queue object in java?
- In C how do you redirect stdin/stdout/stderr to files when making an execvp() or similar call?
- JQuery怎么知道一个元素是否隐藏或显示How do you test if something is hidden in jQuery?
- Java Tips - How do I declare a constant in Java
- ISE Simulator综合后仿真 - How do you run Post Synthesis Simulation in ISE Project Navigator?
- How do you discover your real purpose in life?
- How do you make an object in C? Used in RTOS.
- JQuery怎么知道一个元素是否隐藏或显示How do you test if something is hidden in jQuery?
- osw ERROR. You do not have a legitimate version of java in your PATH
- What is Logical Volume Management and How Do You Enable It in Ubuntu?
- JQuery怎么知道一个元素是否隐藏或显示How do you test if something is hidden in jQuery?
- How do you get the length of a string in jQuery?
- From a response document, how do you update a field in the parent document?
- In an iOS 5 Storyboard, how do you push a new scene to the original view controller from a Popover?
- How do you select a particular option in a SELECT element in jQuery? - Stack Overflow
- How do you copy the contents of an array to a std::vector in C++ without looping? (From stack over flow)