473,473 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

cast

oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1.  public static IBagResult cartesianProduct(IAbstractQueryResult resLeft, 
  2.          IAbstractQueryResult  resRight){
  3.       IBagResult  elements = null;
  4.       List   resLeftL= new ArrayList();
  5.       List   resRightL= new ArrayList();
  6.  
  7.  
  8.      resRightL.add(resRight);
  9.  
  10.      resLeftL.add(resLeft);
  11.  for(int i=0; i<=resLeftL.size(); i++){
  12.  
  13.      for(int j=0; j<= resRightL.size(); j++)
  14.  
  15.      { Integer cP = resLeftL.get(i)*resRightL.get(j);         
  16.  
  17.          elements.addElements(cP);
  18.  
  19.      }   
  20.          }
  21.  return elements;
  22.  
  23.  }
Integer cP = resLeftL.get(i)*resRightL.get(j);

i dont know how to cast it to multiply it
Oct 29 '13 #1
6 1593
Nepomuk
3,112 Recognized Expert Specialist
The way I see it, resLeft and resRight (the elements you're adding to the Lists resLeftL and resRightL respectively) aren't numbers so you can't multiply them. What value from them are you trying to multiply?

Also, you should not use raw Lists. Rather than
Expand|Select|Wrap|Line Numbers
  1. List resLeftL = new ArrayList();
  2. List resRightL = new ArrayList();
you should use
Expand|Select|Wrap|Line Numbers
  1. List<IAbstractQueryResult> resLeftL = new ArrayList<IAbstractQueryResult>();
  2. List<IAbstractQueryResult> resRightL = new ArrayList<IAbstractQueryResult>();
That way the element type returned by resLeftL.get(i) will be known at compile time.
Oct 29 '13 #2
oll3i
679 Contributor
i want two integers passed as (IAbstractQueryResult resLeft,
IAbstractQueryResult resRigh)
cast them to Integer

where should i cast them
Oct 29 '13 #3
oll3i
679 Contributor
Exception in thread "main" java.lang.ClassCastException: s4409_s4409_pr2.IntegerResult cannot be cast to java.lang.Integer
at s09_.QExecUtils.cartesianProduct(QExecUtils.java:4 2)
at s09_s4409_pr2.(_pr2.java:38)
Java Result: 1
Oct 30 '13 #4
oll3i
679 Contributor
how to cast IntegerResult to Integer
Oct 30 '13 #5
oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1. public class IntegerResult implements IIntegerResult{
  2.  Integer i =null;
  3. @Override
  4. public  Integer getValue(){ return i;} 
  5.  
  6. public IntegerResult(Integer i){ 
  7.     this.i=i;
  8. }
  9.  
  10. }
Oct 30 '13 #6
Nepomuk
3,112 Recognized Expert Specialist
You don't cast it, you call the getValue() function on it. That will return an Integer.
Oct 31 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Aaron W. West | last post by:
Fun with CAST! (Optimized SQLServerCentral script posts) I found some interesting "tricks" to convert binary to hexadecimal and back, which allow doing 4 or 8 at a time. Test code first: --...
3
by: Mike | last post by:
I am using MS-Access as a front end for my MS-SQL DB. I have a sql view that uses the following: SELECT TOP 100 PERCENT RECID, PATNUMBER AS , SVCCODE AS , QTY, PROF_CHRGS AS , AMOUNT,...
4
by: Ray | last post by:
When a single-bit bitfield that was formed from an enum is promoted/cast into an integer, does ANSI C say anything about whether that integer should be signed or unsigned? SGI IRIX cc thinks it is...
17
by: Hazz | last post by:
In this sample code of ownerdraw drawmode, why does the '(ComboBox) sender' line of code need to be there in this event handler? Isn't cboFont passed via the managed heap, not the stack, into this...
5
by: Nick Flandry | last post by:
I'm running into an Invalid Cast Exception on an ASP.NET application that runs fine in my development environment (Win2K server running IIS 5) and a test environment (also Win2K server running IIS...
6
by: Lore Leunoeg | last post by:
Hello I derived a class MyControl from the Control class. Public Class MyControl Inherits Control Sub New() MyBase.New() End Sub End Class
9
by: Frederick Gotham | last post by:
Let's assume that we're working on the following system: CHAR_BIT == 8 sizeof( char* ) == 4 (i.e. 32-Bit) Furthermore, lets assume that the memory addresses are distributed as follows: ...
5
by: Frederick Gotham | last post by:
Before I begin, here's a list of assumptions for this particular example: (1) unsigned int has no padding bits, and therefore no invalid bit- patterns or trap representations. (2) All types have...
7
by: * Tong * | last post by:
Hi, I couldn't figure out how to properly type cast in this case: $ cat -n type_cast.c 1 #include <stdio.h> 2 3 typedef unsigned char Byte; 4 typedef signed char Small_Int; 5
2
by: thierry savard | last post by:
I want the 2 compute column to show only 4 decimal, but I cant find a way to affect the return value of 'em. I wrote down this command "compute avg(x)" because I need the average to be in a...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.