Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Other Java > Java GUI
Password Reminder
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Display Modes
  #1 (permalink)  
Old September 8th, 2005, 05:53 PM
Registered User
Join Date: Sep 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Simple Java Program

Hi there,

I have the following program:

public class e1
    public static void main (String[] args){

    byte a = 1;
        while (a<9)
            a++; †

When I try and compile the program I get the following error:

C:\Java\bookwork>javac e1.java
e1.java:8: possible loss of precision
found†††: int
required: byte
                a = a * 2; ††
                    †† ^
1 error

I know that changing the variable "a" from byte to int fixes this problem but how can I make this code work leaving "a" as a byte?

I hope someone can help

Kindest Regards
Reply With Quote
  #2 (permalink)  
Old September 9th, 2005, 12:25 PM
Authorized User
Join Date: Dec 2004
Location: karachi, , Pakistan.
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts

hello friend

here is your program. i use another variable and do casting for it to solve your problem and 'a' remains byte as well. so you can use both of them according to your need .If it does not solve your problem feel free to share your program idea with me.

public class e1
    public static void main (String[] args){

    byte a = 1;
        while (a<9)
    int ab = (int)a*2;


Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
java program help chris1012 Java Basics 3 November 8th, 2007 08:35 AM
Simple assembly program runtime error vraifreud Visual C++ 2005 0 September 21st, 2007 01:20 AM
Simple Program Help hobbit666 Visual Basic 2005 Basics 2 December 19th, 2006 10:51 AM
java program todeepak_g JSP Basics 0 January 25th, 2006 05:04 AM
java program todeepak_g JSP Basics 0 January 25th, 2006 05:01 AM

All times are GMT -4. The time now is 05:56 AM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.