Negative Character Literal?

Jun 3, 2014

char c=(char)-65;

This is legal but how ?? what is the value actually being stored in c ? The output is shown as ﾿.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: JLabel That Robotically Type Words Character By Character

Feb 2, 2015

i want to have a JLabel that could "robotically" type words character by character.

View Replies View Related

Carriage Return Character Working Like New Line Character On MacBook

Nov 21, 2013

I use Eclipse (kepler version, with JDK 7) on MacBook Pro (Lion).I want to overwrite a line printed on my console. I used "" for that. I was expecting the cursor to go to the beginning of the line. Instead, it is going to the next line.

Code:

System.out.print("Superman
Sober");

Expected Output:
Soberman

Actual Output:
----------------
Superman
Sober

View Replies View Related

How To Find XOR Value Of Character Of Character Array In Java

Mar 3, 2015

What I am trying is find the XOR value between charcters of a String here is my code

public static void main(String[] args) {
System.out.println(grayCode("100"));
}
public static String grayCode(String input){
StringBuilder temp=new StringBuilder();
temp.append(input.charAt(0));
for(int j=1;j<input.length();j++){
char previous=input.charAt(j-1);
char current=input.charAt(j);
char xorVal=(char)(previous^current);
temp.append(xorVal);
}
return temp.toString();
}

but I am not getting actual XOR value of two charcters that I am trying to get.

View Replies View Related

Build Up Alphabet Character By Character

Mar 9, 2014

I am trying to build up the alphabet character by character. Like:

a
ab
abc
abcd

Well as of now I can only print out the alphabet with my loop like abcdefg...z.. So here is the code I am trying to use:

public void loop4() {
char alph = 'a';
while(alph <= 'z') {
System.out.println(alph);
alph++; 
}
}

View Replies View Related

Input More Than One Character But Output Is Only One Character

Feb 28, 2015

I have entered more than one character but output is only one character .....

class InputUser
{
public static void main(String arg[])
throws java.io.IOException
{
char ch;
ch=(char) System.in.read();
System.out.println(ch);
}
}

View Replies View Related

Default Literal For Boolean

Mar 31, 2014

what is default literal for Boolean data type?

View Replies View Related

String Concatenation And Literal Pool

Jan 6, 2014

I have a program like below:

final String s1 = "AAA";
final String s2 = "AAA";
String s6 = s1+s2;
String s7 = "AAAAAA";
if ( s6 == s7 ){
System.out.println("s6 and s7 are same" );
}

On running, it prints "s6 and s7 are same". But if i remove the final modifier of s1 and s2 then it's not. What could be the reason?

View Replies View Related

Code Not Printing String Literal

Sep 18, 2014

I need to use print not println to declare stuff and I need to have string literals I think that's /n. Now when I compile it just shows row1, row2 ect. Why does it work like that?

public class art {
public static void main(String[] args) {
//local variables
String row1= "***********************";
String row2= "** *** *** **";
String row3= "** ***** ***** **";

[Code] ...

View Replies View Related

Error - Invalid Float Literal

Apr 26, 2014

While doing trial and error got caught in the below scenario.

public class Crypt {
public static void main (String args[])
{
/*all I want is calculate a binary number (ex -: 22 , 34) using decimal base (10n).
*So, I have to convert 2 p into 10n form so I have to find n in terms of p . We have x as the input.
* The formula works as below.
*2p =10n
*p ln (2) =n ln (10)
*n = p [ln(2) / ln(10)]
*2 p = 10 p [ln(2) / ln(10)]

[Code] ....

View Replies View Related

Why There Is No Literal Representation For Binary Numbers In C / C++ Or Java

May 25, 2015

in Operator/Literals, it says "There is no literal representation for binary numbers in C, C++, or Java." seems "0b11001" could reprensent binary numbers?

int i = 0b100;
System.out.println(i);

the output should be 4.

View Replies View Related

EJB / EE :: Error - Literal Does Not Match Format String

Mar 3, 2015

I'm trying to insert some data of type date into database table using hibernate.i take the input date from an xhtml form as shown below

addEvent.xhtml
Event Date (dd-mon-yy) :
<br/>
<h:inputText id="eventdate" value="#{eventBean.eventDate}" p:required="required"
p:type="date"/>
<p/>
<h:commandButton value="Add Event" actionListener="#{eventBean.addEvent}" />
<p/>

This is my addEvent method in EventBean.java

public void addEvent(ActionEvent evt) {
uname = Util.getUname();
boolean a = EventDAO.add(this);
if ( a) {
message = "Event has been added!";

[Code] ....

While executing this..i get the following error: ORA-01861: literal does not match format string. Could it be due to any mismatch in date format (chrome browser automatically takes date in the format mm-dd-yyyy )? If yes, how do I resolve it? (I'm using Oracle database)

View Replies View Related

Java Literal And Assignment To Different Primary Types

Jan 20, 2015

I thought numeric literal were by default int or doubles, depending on if have a . and numbers after the But I wrote a quick test program as listed below. I understand the float float floatA = 5.5; failed to compile since 5.5 is a literal of type double and you are trying to assign this to a floag

What I am having problems with is byte byteA = 5; 5 is a literal of type int and this is being assigned to a byte and compiler should complain.The compiler does not allow two byte values to be added and assigned to a byte since the result of the addition is an int

class literalTesting{
public static void main(String[] arg){
byte byteA = 5; // allowed WHY I thought literal is an int and assigning int to byte
byte byteB = 10; // allowed

[code]...

View Replies View Related

String Literal Is Not Properly Closed By Double Quote

Apr 28, 2014

I am working with java project which is kind of charting room..but the problem is when am writing the query for listing the message in the conversation the error prevail in my eclipse...string literal is not properly closed by double quote...this is my java file

<%
String uname=session.getAttribute("username").toString();
String pword=session.getAttribute("password").toString();
java.util.Date dat=new Date();
int x=1;
try{

[code]....

View Replies View Related

String Literal Is Not Properly Closed By A Double Quote

Jul 11, 2014

string literal is not properly closed by a double quote

View Replies View Related

Assigning Int Literal To Byte Works But Not As Method Parameter

Apr 23, 2014

If you write

byte b = 100; it works (implicit conversion of implicit int literal 100 to byte.

But if you have a methodvoid bla(byte b){}

And want to invoke it with a literal (which is an int by default):bla(8) then there is no implicit conversion.

Is the byte b = 100; just an exception in Java? And is it the rule that one has to explicitely cast (narrow) integer literals when passing to smaller-than-int types?

View Replies View Related

Can't Get Negative Values Working

Nov 11, 2014

when i input a positive integer it works but when i input a negative number it doesn't work

my pseudo code:

READ input
WHILE( NOT CORRECT INPUT)
READ INPUT AGAIN;
ENDWHILE
DECLARE array arr[input]
FOR(i=0 to input-1)
arr[i]= Random number from 0 to 100;
ENDFOR
DISPLAY ARRAY

error message when i input -5 : Exception in thread "main" java.lang.NegativeArraySizeException atPosNeg.main<PosNeg.java:36>
 
import java.util.*;
class PosNeg{
 public static void main(String args[]) {
  Random generator = new Random();
Scanner scan = new Scanner(System.in);

[code]....

View Replies View Related

Replace Negative Zero With Zero When Printing?

Mar 2, 2015

How do you replace negative zero value with a zero value when Printing results:

I want to remove the minus sign in -0.0000 and instead have 0.0000.

I am Printing coordinates and I do not want to have negative zero.

the coordinates are defined as double.

System.out.format(java.util.Locale.US," %.4f %.4f %.4f %.4f%n"xCur ,yCur,xNext,yNext);

0.0000 1.0000 -0.0000 0.0000

View Replies View Related

Negative Numbers In Binary

Mar 7, 2014

I need understanding why

1111 1101 = -3

View Replies View Related

Subtracting A Negative Fraction?

Mar 10, 2014

For some reason, I'm getting the correct result, but my negative sign is having issues. For example, if I do 1/4 - (-2/4), I get (-3/4).

Here is my minus method for subtracting fractions.

/**
Subtracts a fraction from another fraction.
@param toUse, the fraction to subtract.
@return minusFraction, the result after subtraction.
*/
public Fraction minus(Fraction toUse)

[Code] .....

Here is my reduce() method, just in case...

/**
Reduces the fraction, if possible, to it's simplest form.
Converts negative fractions to the form -x/y, or if -x/-y --> x/y
*/
private void reduce() {
int lowest = Math.abs(numerator);
int highest = Math.abs(denominator);

[code]...

I only switched an operator from my previous addition method, given here as well. I think only switching the + to a - may have caused my issue.

/**
Adds two fractions together.
@param toUse, the fraction to be added.
@return plusFraction, the sum of the two fractions.
*/
public Fraction plus(Fraction toUse) {

[Code] .....

View Replies View Related

Finding Binary Of Negative Numbers?

Mar 22, 2014

How do u find the binary of negative numbers? I already did it for positive numbers,?

View Replies View Related

How To Avoid Getting Negative Numbers Of Coins

Oct 18, 2014

how to avoid getting negative numbers of coins, use casting and mod to show how many quarters, dimes, nickels, and pennies there are?

import java.util.Scanner;

public class VM
{
public static void main(String[] args)
{
//money deposit
Scanner input = new Scanner(System.in);

[code]....

View Replies View Related

Byte Array Negative Values

Mar 30, 2015

I am new to Android. I have byte array of size 10. I am passing the Decimal values (131 - 140) to byte array. But while printing I get Negative (-) values with decreasing order .

How can I get same value as positive values?

Or How can I store positive value e.g. 131 as byte array element.

Please not my requirement is array must be ByteArray only

View Replies View Related

Getting Negative Number For Product Of Odd Integers

Sep 18, 2014

I am not sure what is happening with my code, but it is giving me a negative number. I am trying to write a program that calculates the product of the odd integers between 1 and 25. I messed with the program and as soon as you enter a number over 22, the end result is a negative number.

int total = 1;
for (int i = 1; i <= 25; i += 2){
total *= i;
}
System.out.println("Product:" + total);

View Replies View Related

Raising A Real Number To Negative Value

Jan 21, 2014

I am trying to raise a real number to a negative value e.g x-y(x raised to power -y) which can also be written like 1/xk . I am trying to run th program each time bt it doesnt give me the desired result.

Here is the code

public class RaiseRealPower {
public void run(){
double value =readInt("Enter value ");
double power =readInt("Enter power ");
System.out.println("Answer is " +raiseIntToPower(value,power));

[Code] ....

View Replies View Related

Input Validation For Negative Numbers

Feb 20, 2014

I am very new to Java. I have been working for a couple months on a program for school. It has not gone well. I finally was able to scrap together a working program, but i left something out that needs to be. I have to include input validation to check for negative values, prompting users to re-enter values if negative. I have included my current code, the program works perfectly, but what to do about the negative numbers.

Java Code:

package gradplanner;
import java.util.Scanner;
public class GradPlanner {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int numofclasses = 0;
int totalCUs = 0;

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved