Java object creation storage space - jtag

Given the following code:
class cl
{
int aa = 5;
String st = “Top“;
}
class c2
{
public static void main ()
}
c1 jj = new c1();
}
How is st stored in jj ?
Just as a Reference To the actual String „Top“ or is the Full String Stores within jj ?
Thanks for any help.

Related

How to add class to list in dart?

class CCC {
int num;
CCC(this.num) : this.num = num;
}
void main() {
List list = [];
CCC c1 = CCC(10);
CCC c2 = CCC(20);
print(list);
}
I really don't know. A two-dimensional array is needed in conjunction with the db, but unless you use a class in the list, isn't there an array?
as your question is not clear what you want to ask but what I understand is you want to add class object in list.... For this you have can specify list type then add object of class to it. like,
class CCC{
final int num;
CCC(this.num);
}
void main(){
// specify the list type
List<CCC> list = [];
CCC c1 = CCC(10);
CCC c2 = CCC(20);
list.add(c1);
list.add(c2);
// here you can print all items' property
for (var item in list){
print(item.num);
}
}
I hope I understood your question right

How to pass different data value to Alfresco activiti multi instance subprocess

I have created a multi instance subprocess and the number of subprocesses is created dynamically using Multi-Instance's loopCardinality element but my problem is that I am not able to pass different-different data value to each subprocess.
Image here:
This is my problem scenario as shown in the above image. I want to divide subprocess based on loopCardinality value like:
int getSubProcessDataValue(int fileCount,int loopCardinality){
if(fileCount < 1 && loopCardinality < 1)
return 0
int result=fileCount/loopCardinality;
return result;
}
Suppose fileCount=7 and loopCardinality=2 then the above function will return 3 for the first subprocess. It means I have to pass 3 file names to the first subprocess.
int getLastSubProcessDataValue(int fileCount,int loopCardinality){
if(fileCount < 1 && loopCardinality < 1)
return 0
int result=fileCount/loopCardinality;
int rem=fileCount%loopCardinality;
return result+rem;
}
Suppose fileCount=7 and loopCardinality=2 then the above function will return 4 for the last subprocess. It means I have to pass 4 file names to the last subprocess.
Anyone have an idea how to implement it? Please help me.
This is actually one of the coolest features of the Activiti engine in my opinion.
You do this by using the collection option rather than setting the cardinality.
The collection and elementValue options as shown below:
Here the number of instances will be determined by the size of the collection and the input variables "elementValue" will be the list element.
Using this approach you can pass different data into each instance of the multi instance loop.
Hope this helps,
Greg
I have done it using TaskListener as shown below code:
package com.knovel.workflow.scripts;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
public class FileSplittingTaskListener implements TaskListener{
private static final long serialVersionUID = 3972525330472103945L;
#Override
public void notify(DelegateTask task) {
System.out.println("#####FileSplittingTaskListener######");
task.setVariable("bpm_assignee", task.getVariable("bpm_assignee"));
task.setVariable("bpm_comment", task.getVariable("bpm_comment"));
task.setVariable("bpm_dueDate", task.getDueDate());
task.setVariable("bpm_priority", task.getPriority());
String strFileSplitter=(String)task.getVariable("wf_fileSplitter");
System.out.println("#############FileSplitter >>"+strFileSplitter);
Integer fileSplitter=Integer.parseInt(strFileSplitter);
System.out.println("#############FileSplitter >>"+fileSplitter);
//task.setVariable("wf_taskCounter", fileSplitter);
String workFlowFileName=(String)
task.getVariable("wf_workFlowFileName");
String[] files=workFlowFileName.split("-");
System.out.println("#######Files Length:"+files.length);
List<String[]> filesList = splitArray(files, fileSplitter);
List<String> fileList=new ArrayList<>();
for (String[] lists : filesList) {
String fileName="";
int srNo=0;
int count=1;
for (String string : lists) {
System.out.println("File>>"+string);
if(count == lists.length){
fileName=fileName+ ++srNo +"-"+string;
}else{
fileName=fileName+ ++srNo +"-"+string+",";
}
count++;
}
fileList.add(fileName);
srNo=0;
}
System.out.println("FileList>>"+fileList);
System.out.println("#############FileList >>"+fileList);
task.setVariable("filesList", fileList);
}
public static <T extends Object> List<T[]> splitArray(T[] array, int
max){
int x = array.length / max;
int r = (array.length % max); // remainder
int lower = 0;
int upper = 0;
List<T[]> list = new ArrayList<T[]>();
int i=0;
for(i=0; i<x; i++){
upper += max;
list.add(Arrays.copyOfRange(array, lower, upper));
lower = upper;
}
if(r > 0){
list.add(Arrays.copyOfRange(array, lower, (lower + r)));
}
return list;
}
}
And I have updated multiInstanceLoopCharacteristics element properties as shown below:
<multiInstanceLoopCharacteristics
isSequential="false"
activiti:collection="filesList"
activiti:elementVariable="wf_workFlowFileName">
</multiInstanceLoopCharacteristics>
Thank you so much for your valuable supports!!!

C++ Accessing variables in a function in one class from a different class

I'm trying to code a program with multiple classes such the one of the class reads the variables from a text file and the other classes use these variables for further processing.
The problem I'm facing is that I'm having trouble passing the variables from one class to another class, I did try "friend" class and also tried to use constructors but failed
to get the desired output.
The best I could do was
suppose I have class 1 and class 2, and I have a variable "A=10" declared and initialised in class 1, with the help of constructor I inherit it in class 2;
when I print it in class 1, it gives a correct output as 10 but when I print it in class 2 it gives an output as 293e30 (address location)
Please guide me on how to this.
Class1
{
public:
membfunc()
{
int A;
A = 10;
}
}
Class2
{
public:
membfunc2()
{
int B;
B = A + 10;
}
membfunc3()
{
int C, D;
C = A + 10;
D = B + C;
}
}
If i print variables, i expect to get
A = 10, B = 20, C = 20, D = 40
But what I get is
A = 10, B=(252e30) + 10
I think your problem was that you were defining local variables in your member functions, instead of creating member variables of a class object.
Here is some code based on your sample to demonstrate how member variables work:
class Class1
{
public:
int A;
void membfunc()
{
A=10;
}
};
class Class2
{
public:
int B;
int C;
int D;
void membfunc2(Class1& class1Object)
{
B = class1Object.A + 10;
}
void membfunc3(Class1& class1Object)
{
C = class1Object.A + 10;
D = B + C;
}
};
(Full code sample here: http://ideone.com/cwZ6DM.)
You can learn more about member variables (properties and fields) here: http://www.cplusplus.com/doc/tutorial/classes/.

UnityScript - How To Loop Through Public Properties of A Class

I have the following script in UnityScript, which is called JavaScript in Unity Editor but is not quite the same especially for looping through objects.
public class UpgradeProfile extends MonoBehaviour {
public var brakeSpeed : float = 0;
public var jumpForce : float = 0;
public var maxJumps : int = 1;
};
How can I loop through all the properties of this class and, for example, log the values or sum them with the values of another member of the same class?
Note: UnityScript is not JavaScript or C# so answers relating to those languages do not answer this question.
This works for me to get the properites and values.
#pragma strict
public var test1 = 10;
public var test2 = 11;
function Start ()
{
for(var property in this.GetType().GetFields())
{
Debug.Log("Name: " + property.Name + " Value: " + property.GetValue(this));
}
}
And this prints out
Name: test1 Value: 10
Name: test2 Value: 11
And if you want to do this with another component, replace this with a component instead

ActionScript: How to sort a class vector based on int

I have a vector of TestClass objects that I would like to arrange in ascending order based on integer of each TestClass object. How would I do this?
Main Method:
public class testSave extends Sprite
{
public function testSave()
{
var testVector:Vector.<TestClass> = new Vector.<TestClass>;
testVector.push(new TestClass(5, "Testing"), new TestClass(2, "HelloWorld"), new TestClass(7, "Ohai");
}
}
TestClass
public class TestClass
{
public function TestClass(testi:int, tests:String)
{
this.stest = tests;
this.itest = testi
}
public var stest:String;
public var itest:int;
}
Unfortunately there is no sortOn for Vectors but there is a sort. So if you do this:
public function testSave():void {
var testVector:Vector.<TestClass> = new Vector.<TestClass>;
testVector.push(new TestClass(5, "Testing"), new TestClass(2, "HelloWorld"), new TestClass(7, "Ohai"));
testVector.sort(function(a:TestClass, b:TestClass):Boolean {
return a.itest > b.itest;
});
// confirm the vector is now sorted
for (var i = 0; i < testVector.length; i++){
trace(testVector[i].itest);
}
}
your vector will sort. Vector.sort takes a sorting function, it compares the two values and then figures out how to swap them when iterating through the array...
Checking if a is greater than b will result in ascending order.