Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:23:35+00:00 2026-06-02T02:23:35+00:00

what is wrong with this; public class cast { public static void main(String args[]){

  • 0

what is wrong with this;

public class cast {

    public static void main(String args[]){
        double x, y; 
        int i;
        char c; 

        x = 10.0; 
        y = 3.0; 

        i = (int) (x / y); 
        System.out.println("Integer outcome of x / y = " + i); 

        i = 100; //Assaigning new value to i. 

        b = (byte) i;  
        System.out.println("The value of i is: " + b); 

    }

}

It gives me the following error message;
b cannot be resolved to a variable.

Although I did exactly as they did in the book ( I think, re read the book instruction like five times….)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:23:38+00:00Added an answer on June 2, 2026 at 2:23 am

    b is not a declared variable in your example. Before you can use a variable you have to declare it. If you don’t do this Java does not know what b stands for and doesn’t know what to do with it. Try

    byte b = (byte) i; 
    

    instead. Alternatively you can also add the line

    byte b;
    

    to the beginning of your program. This tells Java that you want b to be a variable that can hold a byte.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone tell me what is wrong with this code? public abstract class BoardTestBean{
I wrote this utility function: public static <T> List<T> pluck(String fieldName, List list) throws
Can anyone see anything wrong with this login script: public function login($username, $pass, $remember)
Is there anything wrong with this code? My entity is not getting updated. public
Whats wrong with this code? -(void) drawRect:(CGRect) rect { CGContextRef c = UIGraphicsGetCurrentContext(); if
I have this simple structure: 1 parent, and two different childs. public class Parent{}
I'm trying to build an object that looks something like this: public class MyObject
My problem can be summed-up by this snippet: public interface TheClass<T> { public void
I have a linq query as follow: public static ViewUserDisplayPreferences GetUserDisplayPreferences(int TheUserID) { using
I've instrumented my class using ASM and processed it like this public class MyClassLoader

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.