Excel Mac Error

Fix: Office 2016 Grant Access Error on MacOS

Posted in Compus, General

Remove Firt or last N character

1.1 Remove first N characters with RIGHT / REPLACE function

>> Combine RIGHT and LEN function to remove first N characters

Formula syntax and arguments

Formula:    =RIGHT(string_cell,LEN(string_cell)-n_character)

Reference: string_cell: the cell you use to remove characters

n_character: the number of characters you want to remove

Example: Remove first 2 characters from string in Cell A2, copy and paste the formula
press Enter key
doc remove first last 2


Posted in Compus, General, Tech

Java Ignore Case

      String Str1 = new String("This is really not immutable!!");
      String Str2 = Str1;
      String Str3 = new String("This is really not immutable!!");
      String Str4 = new String("This IS REALLY NOT IMMUTABLE!!");
      boolean retVal;

      retVal = Str1.equals( Str2 );
      System.out.println("Returned Value = " + retVal );

      retVal = Str1.equals( Str3 );
      System.out.println("Returned Value = " + retVal );

      retVal = Str1.equalsIgnoreCase( Str4 );
      System.out.println("Returned Value = " + retVal );

This will produce the following result −


Returned Value = true
Returned Value = true
Returned Value = true


Posted in Compus | Tagged

Java Integrer to String Examples


Convert using Integer.toString(int)

The Integer class has a static method that returns a String object representing the specified int parameter. Using this is an efficient solution.


public static String toString(int i)

The argument i is converted and returned as a string instance. If the number is negative, the sign will be preserved.


int number = -782;
String numberAsString = Integer.toString(number);

The code is equivalent to:

String numberAsString = "-782";

If you will try and search for solutions, this is one of the most popular ways of converting an int to String.

Convert using String.valueOf(int)

The String class has several static methods that can convert most primitive types to their String representation. This includes integers.


int number = -782;
String numberAsString = String.valueOf(number);


String numberAsString = String.valueOf(-782);

This is also an efficient solution like the first option above. And because this is simple and efficient, it is also a very popular method for converting an int to String.



Posted in Compus, General | Tagged

String types

2.1  String Literal vs. String Object


As mentioned, there are two ways to construct a string: implicit construction by assigning a string literal or explicitly creating a String object via the new operator and constructor. For example,

String s1 = "Hello";              // String literal
String s2 = "Hello";              // String literal
String s3 = s1;                   // same reference
String s4 = new String("Hello");  // String object
String s5 = new String("Hello");  // String object

Java has provided a special mechanism for keeping the String literals – in a so-called string common pool. If two string literals have the same contents, they will share the same storage inside the common pool. This approach is adopted to conserve storage for frequently-used strings. On the other hand, String objects created via the new operator and constructor are kept in the heap. Each String object in the heap has its own storage just like any other object. There is no sharing of storage in heap even if two String objects have the same contents.

You can use the method equals() of the String class to compare the contents of two Strings. You can use the relational equality operator '==' to compare the references (or pointers) of two objects. Study the following codes:

s1 == s1;         // true, same pointer
s1 == s2;         // true, s1 and s1 share storage in common pool
s1 == s3;         // true, s3 is assigned same pointer as s1
s1.equals(s3);    // true, same contents
s1 == s4;         // false, different pointers
s1.equals(s4);    // true, same contents
s4 == s5;         // false, different pointers in heap
s4.equals(s5);    // true, same contents

Important Notes:

  • In the above example, I used relational equality operator '==' to compare the references of two String objects. This is done to demonstrate the differences between string literals sharing storage in the common pool and String objects created in the heap. It is a logical error to use (str1 == str2) in your program to compare the contents of two Strings.
  • String can be created by directly assigning a String literal which is shared in a common pool. It is uncommon and not recommended to use the new operator to construct a String object in the heap.

[TODO] Explain the method String.intern().



Posted in Compus | Tagged

Java convert String to Int

In Java, you can use Integer.parseInt() to convert a String to int.

1. Integer.parseInt() Examples

Example to convert a String “10” to an primitive int.

String number = "10";
int result = Integer.parseInt(number);



2. Integer.valueOf() Examples

Alternatively, you can use Integer.valueOf(), it will returns an Integer object.

String number = "10";
Integer result = Integer.valueOf(number);


In summary, parseInt(String) returns a primitive int, whereas valueOf(String) returns a new Integer() object.
Fuente: https://www.mkyong.com/java/java-convert-string-to-int/
Posted in Compus, General | Tagged

Talend Merge Files into one


Posted in Compus | Tagged